Add test array-type-no-semi.rs

Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
This commit is contained in:
xizheyin 2025-07-14 03:39:24 +08:00
parent 7e310f4b9a
commit 1cac8cbde9
No known key found for this signature in database
GPG key ID: 0A0D90BE99CEDEAD
2 changed files with 74 additions and 0 deletions

View file

@ -0,0 +1,18 @@
// when the next token is not a semicolon,
// we should suggest to use semicolon if recovery is allowed
// See issue #143828
fn main() {
let x = 5;
let b: [i32, 5];
//~^ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `,`
//~| ERROR expected value, found builtin type `i32` [E0423]
let a: [i32, ];
//~^ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `,`
//~| ERROR expected value, found builtin type `i32` [E0423]
let c: [i32, x];
//~^ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `,`
//~| ERROR expected value, found builtin type `i32` [E0423]
let e: [i32 5];
//~^ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `5`
}

View file

@ -0,0 +1,56 @@
error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `,`
--> $DIR/array-type-no-semi.rs:7:16
|
LL | let b: [i32, 5];
| - ^ expected one of 7 possible tokens
| |
| while parsing the type for `b`
| help: use `=` if you meant to assign
error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `,`
--> $DIR/array-type-no-semi.rs:10:16
|
LL | let a: [i32, ];
| - ^ expected one of 7 possible tokens
| |
| while parsing the type for `a`
| help: use `=` if you meant to assign
error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `,`
--> $DIR/array-type-no-semi.rs:13:16
|
LL | let c: [i32, x];
| - ^ expected one of 7 possible tokens
| |
| while parsing the type for `c`
| help: use `=` if you meant to assign
error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `5`
--> $DIR/array-type-no-semi.rs:16:17
|
LL | let e: [i32 5];
| - ^ expected one of 7 possible tokens
| |
| while parsing the type for `e`
error[E0423]: expected value, found builtin type `i32`
--> $DIR/array-type-no-semi.rs:7:13
|
LL | let b: [i32, 5];
| ^^^ not a value
error[E0423]: expected value, found builtin type `i32`
--> $DIR/array-type-no-semi.rs:10:13
|
LL | let a: [i32, ];
| ^^^ not a value
error[E0423]: expected value, found builtin type `i32`
--> $DIR/array-type-no-semi.rs:13:13
|
LL | let c: [i32, x];
| ^^^ not a value
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0423`.