Skip to content

Commit 4b094c5

Browse files
authored
Rollup merge of #106494 - JohnTitor:issue-58355, r=compiler-errors
Add regression test for #58355 Closes #58355 r? `@compiler-errors` Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2 parents 2b6e38c + b83fa06 commit 4b094c5

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/test/ui/type/issue-58355.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![crate_type = "lib"]
2+
3+
pub fn foo(callback: fn() -> dyn ToString) {
4+
let mut x: Option<Box<dyn Fn() -> dyn ToString>> = None;
5+
x = Some(Box::new(callback));
6+
//~^ ERROR: the size for values of type `dyn ToString` cannot be known at compilation time
7+
}

src/test/ui/type/issue-58355.stderr

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0277]: the size for values of type `dyn ToString` cannot be known at compilation time
2+
--> $DIR/issue-58355.rs:5:14
3+
|
4+
LL | x = Some(Box::new(callback));
5+
| ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
6+
|
7+
= help: within `fn() -> dyn ToString`, the trait `Sized` is not implemented for `dyn ToString`
8+
= note: required because it appears within the type `fn() -> dyn ToString`
9+
= note: required for the cast from `fn() -> dyn ToString` to the object type `dyn Fn() -> (dyn ToString + 'static)`
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)