about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/parser/recover/array-type-no-semi.rs18
-rw-r--r--tests/ui/parser/recover/array-type-no-semi.stderr56
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`.