diff options
| author | xizheyin <xizheyin@smail.nju.edu.cn> | 2025-07-14 03:39:24 +0800 |
|---|---|---|
| committer | xizheyin <xizheyin@smail.nju.edu.cn> | 2025-07-14 14:26:47 +0800 |
| commit | 1cac8cbde98e7b15ad24fc96af4864cdd67b9c30 (patch) | |
| tree | 6b5dc877fe62ac93c4ce3a3612a46dda02d1d6d0 | |
| parent | 7e310f4b9a3f166d833ed09cf1d1ff96ab84b72c (diff) | |
| download | rust-1cac8cbde98e7b15ad24fc96af4864cdd67b9c30.tar.gz rust-1cac8cbde98e7b15ad24fc96af4864cdd67b9c30.zip | |
Add test array-type-no-semi.rs
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
| -rw-r--r-- | tests/ui/parser/recover/array-type-no-semi.rs | 18 | ||||
| -rw-r--r-- | tests/ui/parser/recover/array-type-no-semi.stderr | 56 |
2 files changed, 74 insertions, 0 deletions
diff --git a/tests/ui/parser/recover/array-type-no-semi.rs b/tests/ui/parser/recover/array-type-no-semi.rs new file mode 100644 index 00000000000..ae5efbaf36c --- /dev/null +++ b/tests/ui/parser/recover/array-type-no-semi.rs @@ -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` +} diff --git a/tests/ui/parser/recover/array-type-no-semi.stderr b/tests/ui/parser/recover/array-type-no-semi.stderr new file mode 100644 index 00000000000..84b7282b4fe --- /dev/null +++ b/tests/ui/parser/recover/array-type-no-semi.stderr @@ -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`. |
