File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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`.
You can’t perform that action at this time.
0 commit comments