Skip to content

Commit 8ab5be1

Browse files
committed
Add tests verifying rust-lang#50940.
1 parent 8b42623 commit 8ab5be1

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+
fn main() {
4+
struct A<X: ?Sized>(X);
5+
A as fn(str) -> A<str>;
6+
//~^ERROR the size for values of type `str` cannot be known at compilation time
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0277]: the size for values of type `str` cannot be known at compilation time
2+
--> $DIR/issue-50940-with-feature.rs:5:5
3+
|
4+
LL | A as fn(str) -> A<str>;
5+
| ^ doesn't have a size known at compile-time
6+
|
7+
= help: within `main::A<str>`, the trait `std::marker::Sized` is not implemented for `str`
8+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
9+
= note: required because it appears within the type `main::A<str>`
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+
fn main() {
2+
struct A<X: ?Sized>(X);
3+
A as fn(str) -> A<str>;
4+
//~^ERROR the size for values of type `str` cannot be known at compilation time
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0277]: the size for values of type `str` cannot be known at compilation time
2+
--> $DIR/issue-50940.rs:3:5
3+
|
4+
LL | A as fn(str) -> A<str>;
5+
| ^ doesn't have a size known at compile-time
6+
|
7+
= help: the trait `std::marker::Sized` is not implemented for `str`
8+
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/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)