Skip to content

Commit 74ca981

Browse files
committed
add test for #88212 ICE when lambda captures unsized local
Fixes #88212
1 parent 445507a commit 74ca981

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// ICE size_and_align_of::<[[email protected]:15:5: 17:7]> not supported #88212
2+
3+
#![feature(unsized_locals)]
4+
//~^ WARN the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes
5+
6+
trait Example {}
7+
struct Foo();
8+
9+
impl Example for Foo {}
10+
11+
fn example() -> Box<dyn Example> {
12+
Box::new(Foo())
13+
}
14+
15+
fn main() {
16+
let x: dyn Example = *example();
17+
(move || {
18+
let _y = x;
19+
//~^ ERROR the size for values of type `dyn Example` cannot be known at compilation time
20+
})();
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/ice-size_and_align_of-closure-not-supported-88212.rs:3:12
3+
|
4+
LL | #![feature(unsized_locals)]
5+
| ^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error[E0277]: the size for values of type `dyn Example` cannot be known at compilation time
11+
--> $DIR/ice-size_and_align_of-closure-not-supported-88212.rs:18:18
12+
|
13+
LL | (move || {
14+
| -- this closure captures all values by move
15+
LL | let _y = x;
16+
| ^ doesn't have a size known at compile-time
17+
|
18+
= help: the trait `Sized` is not implemented for `dyn Example`
19+
= note: all values captured by value by a closure must have a statically known size
20+
21+
error: aborting due to 1 previous error; 1 warning emitted
22+
23+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)