-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check that closure's by-value captures are sized
- Loading branch information
1 parent
2d08657
commit c21867f
Showing
6 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// compile-flags: --crate-type=lib | ||
|
||
#![feature(unsized_fn_params)] | ||
|
||
pub fn f(k: dyn std::fmt::Display) { | ||
let k2 = move || { | ||
k.to_string(); | ||
//~^ ERROR the size for values of type `(dyn std::fmt::Display + 'static)` cannot be known at compilation time | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0277]: the size for values of type `(dyn std::fmt::Display + 'static)` cannot be known at compilation time | ||
--> $DIR/capture-unsized-by-move.rs:7:9 | ||
| | ||
LL | let k2 = move || { | ||
| -- this closure captures all values by move | ||
LL | k.to_string(); | ||
| ^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `(dyn std::fmt::Display + 'static)` | ||
= note: all values captured by value by a closure must have a statically known size | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// build-pass | ||
// compile-flags: --crate-type=lib | ||
|
||
#![feature(unsized_fn_params)] | ||
|
||
pub fn f(k: dyn std::fmt::Display) { | ||
let k2 = || { | ||
k.to_string(); | ||
}; | ||
} |