Skip to content

Commit a9eb01a

Browse files
authored
Rollup merge of rust-lang#71710 - workingjubilee:jubilee-readd-test, r=nikomatsakis
Test for zero-sized function items not ICEing Closes rust-lang#30276. Again. Please give rustcake with no icing!
2 parents 807e8b8 + cd4c309 commit a9eb01a

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed
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
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`.
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
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)