Skip to content

Commit a3470b1

Browse files
committed
Test that unsized locals fail when turning unsized_fn_params feature flag on
1 parent f0a71f7 commit a3470b1

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![feature(unsized_fn_params)]
2+
3+
fn main() {
4+
let foo: Box<[u8]> = Box::new(*b"foo");
5+
let _foo: [u8] = *foo;
6+
//~^ ERROR: the size for values of type `[u8]` cannot be known at compilation time [E0277]
7+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
2+
--> $DIR/unsized-locals-using-unsized-fn-params.rs:5:9
3+
|
4+
LL | let _foo: [u8] = *foo;
5+
| ^^^^ doesn't have a size known at compile-time
6+
|
7+
= help: the trait `Sized` is not implemented for `[u8]`
8+
= note: all local variables must have a statically known size
9+
= help: unsized locals are gated as an unstable feature
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)