Skip to content

Commit 845aa63

Browse files
Add regression test for #143128
1 parent a86b331 commit 845aa63

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

tests/ui/closures/missing-body.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Checks that the compiler complains about the missing closure body and does not
2+
// crash.
3+
// This is a regression test for <https://github.com/rust-lang/rust/issues/143128>.
4+
5+
fn main() { | b : [str; _] | }
6+
//~^ ERROR expected expression, found `}`
7+
//~| ERROR the placeholder `_` is not allowed within types on item signatures for closures
8+
//~| ERROR the size for values of type `str` cannot be known at compilation time

tests/ui/closures/missing-body.stderr

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
error: expected expression, found `}`
2+
--> $DIR/missing-body.rs:5:30
3+
|
4+
LL | fn main() { | b : [str; _] | }
5+
| ---------------- ^ expected expression
6+
| |
7+
| while parsing the body of this closure
8+
|
9+
help: you might have meant to open the body of the closure, instead of enclosing the closure in a block
10+
|
11+
LL - fn main() { | b : [str; _] | }
12+
LL + fn main() | b : [str; _] | { }
13+
|
14+
15+
error[E0121]: the placeholder `_` is not allowed within types on item signatures for closures
16+
--> $DIR/missing-body.rs:5:25
17+
|
18+
LL | fn main() { | b : [str; _] | }
19+
| ^ not allowed in type signatures
20+
21+
error[E0277]: the size for values of type `str` cannot be known at compilation time
22+
--> $DIR/missing-body.rs:5:19
23+
|
24+
LL | fn main() { | b : [str; _] | }
25+
| ^^^^^^^^ doesn't have a size known at compile-time
26+
|
27+
= help: the trait `Sized` is not implemented for `str`
28+
= note: slice and array elements must have `Sized` type
29+
30+
error: aborting due to 3 previous errors
31+
32+
Some errors have detailed explanations: E0121, E0277.
33+
For more information about an error, try `rustc --explain E0121`.

0 commit comments

Comments
 (0)