Skip to content

Commit cd4c309

Browse files
Test for zero-sized function items not ICEing
1 parent bf45975 commit cd4c309

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![feature(unsized_locals)]
2+
3+
struct Test([i32]);
4+
5+
fn main() {
6+
let _x: fn(_) -> Test = Test;
7+
} //~^the size for values of type `[i32]` cannot be known at compilation time
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
2+
--> $DIR/issue-30276-feature-flagged.rs:6:29
3+
|
4+
LL | let _x: fn(_) -> Test = Test;
5+
| ^^^^ doesn't have a size known at compile-time
6+
|
7+
= help: within `Test`, the trait `std::marker::Sized` is not implemented for `[i32]`
8+
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
9+
= note: required because it appears within the type `Test`
10+
= note: the return type of a function must have a statically known size
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
struct Test([i32]);
2+
3+
fn main() {
4+
let _x: fn(_) -> Test = Test;
5+
} //~^the size for values of type `[i32]` cannot be known at compilation time
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
2+
--> $DIR/issue-30276.rs:4:29
3+
|
4+
LL | let _x: fn(_) -> Test = Test;
5+
| ^^^^ doesn't have a size known at compile-time
6+
|
7+
= help: the trait `std::marker::Sized` is not implemented for `[i32]`
8+
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
9+
= note: all function arguments must have a statically known size
10+
= help: unsized locals are gated as an unstable feature
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)