Skip to content

Commit b83fa06

Browse files
committed
Add regression test for rust-lang#58355
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
1 parent e94fab6 commit b83fa06

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)