From b83fa06c561dbccb1cdb35c4862d4f47969a1cab Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 6 Jan 2023 00:24:42 +0900 Subject: [PATCH] Add regression test for #58355 Signed-off-by: Yuki Okushi --- src/test/ui/type/issue-58355.rs | 7 +++++++ src/test/ui/type/issue-58355.stderr | 13 +++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/test/ui/type/issue-58355.rs create mode 100644 src/test/ui/type/issue-58355.stderr diff --git a/src/test/ui/type/issue-58355.rs b/src/test/ui/type/issue-58355.rs new file mode 100644 index 0000000000000..3b62fdece403b --- /dev/null +++ b/src/test/ui/type/issue-58355.rs @@ -0,0 +1,7 @@ +#![crate_type = "lib"] + +pub fn foo(callback: fn() -> dyn ToString) { + let mut x: Option dyn ToString>> = None; + x = Some(Box::new(callback)); + //~^ ERROR: the size for values of type `dyn ToString` cannot be known at compilation time +} diff --git a/src/test/ui/type/issue-58355.stderr b/src/test/ui/type/issue-58355.stderr new file mode 100644 index 0000000000000..6f89a7b004999 --- /dev/null +++ b/src/test/ui/type/issue-58355.stderr @@ -0,0 +1,13 @@ +error[E0277]: the size for values of type `dyn ToString` cannot be known at compilation time + --> $DIR/issue-58355.rs:5:14 + | +LL | x = Some(Box::new(callback)); + | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `fn() -> dyn ToString`, the trait `Sized` is not implemented for `dyn ToString` + = note: required because it appears within the type `fn() -> dyn ToString` + = note: required for the cast from `fn() -> dyn ToString` to the object type `dyn Fn() -> (dyn ToString + 'static)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`.