summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-10-28 21:35:58 +0100
committerGitHub <noreply@github.com>2019-10-28 21:35:58 +0100
commit2fe6f22dea25dd7498b2acb0f0156563644a13f2 (patch)
tree1b750d9b784fc10e9690b0a6d853edc2c5d1832c /src/test/ui/parser
parenteec3a9c4af5067c37f5b681599a48b4e21098260 (diff)
parente8016c2b13a7e16b6eed9e30b4b6bfe304750566 (diff)
downloadrust-2fe6f22dea25dd7498b2acb0f0156563644a13f2.tar.gz
rust-2fe6f22dea25dd7498b2acb0f0156563644a13f2.zip
Rollup merge of #65640 - estebank:recover-missing-semi, r=Centril
Use heuristics to recover parsing of missing `;`

- Detect `,` and `:` typos where `;` was intended.
- When the next token could have been the start of a new statement,
  detect a missing semicolon.

Fix #48160, fix #44767 (after adding note about statements).
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/default.stderr2
-rw-r--r--src/test/ui/parser/duplicate-visibility.stderr2
-rw-r--r--src/test/ui/parser/extern-expected-fn-or-brace.rs2
-rw-r--r--src/test/ui/parser/extern-expected-fn-or-brace.stderr2
-rw-r--r--src/test/ui/parser/impl-parsing.stderr2
-rw-r--r--src/test/ui/parser/issue-15980.rs2
-rw-r--r--src/test/ui/parser/issue-15980.stderr2
-rw-r--r--src/test/ui/parser/issue-19398.rs2
-rw-r--r--src/test/ui/parser/issue-19398.stderr4
-rw-r--r--src/test/ui/parser/issue-3036.rs4
-rw-r--r--src/test/ui/parser/issue-3036.stderr8
-rw-r--r--src/test/ui/parser/macro/trait-non-item-macros.stderr2
-rw-r--r--src/test/ui/parser/raw/raw-literal-keywords.rs2
-rw-r--r--src/test/ui/parser/raw/raw-literal-keywords.stderr2
-rw-r--r--src/test/ui/parser/recover-for-loop-parens-around-head.rs2
-rw-r--r--src/test/ui/parser/recover-for-loop-parens-around-head.stderr2
-rw-r--r--src/test/ui/parser/recover-missing-semi.rs4
-rw-r--r--src/test/ui/parser/recover-missing-semi.stderr20
-rw-r--r--src/test/ui/parser/removed-syntax-static-fn.stderr2
-rw-r--r--src/test/ui/parser/removed-syntax-uniq-mut-ty.rs3
-rw-r--r--src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr2
-rw-r--r--src/test/ui/parser/underscore_item_not_const.rs2
-rw-r--r--src/test/ui/parser/underscore_item_not_const.stderr2
23 files changed, 39 insertions, 38 deletions
diff --git a/src/test/ui/parser/default.stderr b/src/test/ui/parser/default.stderr
index e199045134e..8843fd303ec 100644
--- a/src/test/ui/parser/default.stderr
+++ b/src/test/ui/parser/default.stderr
@@ -1,4 +1,4 @@
-error: expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, found `pub`
+error: expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, found keyword `pub`
   --> $DIR/default.rs:22:13
    |
 LL |     default pub fn foo<T: Default>() -> T { T::default() }
diff --git a/src/test/ui/parser/duplicate-visibility.stderr b/src/test/ui/parser/duplicate-visibility.stderr
index 880b536cd18..675adb88d20 100644
--- a/src/test/ui/parser/duplicate-visibility.stderr
+++ b/src/test/ui/parser/duplicate-visibility.stderr
@@ -1,4 +1,4 @@
-error: expected one of `(`, `fn`, `static`, or `type`, found `pub`
+error: expected one of `(`, `fn`, `static`, or `type`, found keyword `pub`
   --> $DIR/duplicate-visibility.rs:3:9
    |
 LL |     pub pub fn foo();
diff --git a/src/test/ui/parser/extern-expected-fn-or-brace.rs b/src/test/ui/parser/extern-expected-fn-or-brace.rs
index dd46b87fa42..907de0d8f91 100644
--- a/src/test/ui/parser/extern-expected-fn-or-brace.rs
+++ b/src/test/ui/parser/extern-expected-fn-or-brace.rs
@@ -1,4 +1,4 @@
 // Verifies that the expected token errors for `extern crate` are
 // raised
 
-extern "C" mod foo; //~ERROR expected one of `fn` or `{`, found `mod`
+extern "C" mod foo; //~ERROR expected one of `fn` or `{`, found keyword `mod`
diff --git a/src/test/ui/parser/extern-expected-fn-or-brace.stderr b/src/test/ui/parser/extern-expected-fn-or-brace.stderr
index 0fb99355341..691f4cddff2 100644
--- a/src/test/ui/parser/extern-expected-fn-or-brace.stderr
+++ b/src/test/ui/parser/extern-expected-fn-or-brace.stderr
@@ -1,4 +1,4 @@
-error: expected one of `fn` or `{`, found `mod`
+error: expected one of `fn` or `{`, found keyword `mod`
   --> $DIR/extern-expected-fn-or-brace.rs:4:12
    |
 LL | extern "C" mod foo;
diff --git a/src/test/ui/parser/impl-parsing.stderr b/src/test/ui/parser/impl-parsing.stderr
index 935e93963e1..e929fa53620 100644
--- a/src/test/ui/parser/impl-parsing.stderr
+++ b/src/test/ui/parser/impl-parsing.stderr
@@ -26,7 +26,7 @@ error: expected `impl`, found `FAIL`
   --> $DIR/impl-parsing.rs:11:16
    |
 LL | default unsafe FAIL
-   |                ^^^^ expected `impl` here
+   |                ^^^^ expected `impl`
 
 error: aborting due to 5 previous errors
 
diff --git a/src/test/ui/parser/issue-15980.rs b/src/test/ui/parser/issue-15980.rs
index ba874fb4476..beb94c8042d 100644
--- a/src/test/ui/parser/issue-15980.rs
+++ b/src/test/ui/parser/issue-15980.rs
@@ -11,7 +11,7 @@ fn main(){
         }
         //~^ NOTE expected one of `.`, `=>`, `?`, or an operator here
         _ => {}
-        //~^ ERROR expected one of `.`, `=>`, `?`, or an operator, found `_`
+        //~^ ERROR expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_`
         //~| NOTE unexpected token
     }
 }
diff --git a/src/test/ui/parser/issue-15980.stderr b/src/test/ui/parser/issue-15980.stderr
index 47c275110b4..26f75d45fa2 100644
--- a/src/test/ui/parser/issue-15980.stderr
+++ b/src/test/ui/parser/issue-15980.stderr
@@ -12,7 +12,7 @@ help: you can escape reserved keywords to use them as identifiers
 LL |             r#return
    |
 
-error: expected one of `.`, `=>`, `?`, or an operator, found `_`
+error: expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_`
   --> $DIR/issue-15980.rs:13:9
    |
 LL |         }
diff --git a/src/test/ui/parser/issue-19398.rs b/src/test/ui/parser/issue-19398.rs
index 822f4a6fde2..90221039b41 100644
--- a/src/test/ui/parser/issue-19398.rs
+++ b/src/test/ui/parser/issue-19398.rs
@@ -1,5 +1,5 @@
 trait T {
-    extern "Rust" unsafe fn foo(); //~ ERROR expected `fn`, found `unsafe`
+    extern "Rust" unsafe fn foo(); //~ ERROR expected `fn`, found keyword `unsafe`
 }
 
 fn main() {}
diff --git a/src/test/ui/parser/issue-19398.stderr b/src/test/ui/parser/issue-19398.stderr
index d5f1f972d55..41ec4f3ced4 100644
--- a/src/test/ui/parser/issue-19398.stderr
+++ b/src/test/ui/parser/issue-19398.stderr
@@ -1,8 +1,8 @@
-error: expected `fn`, found `unsafe`
+error: expected `fn`, found keyword `unsafe`
   --> $DIR/issue-19398.rs:2:19
    |
 LL |     extern "Rust" unsafe fn foo();
-   |                   ^^^^^^ expected `fn` here
+   |                   ^^^^^^ expected `fn`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/parser/issue-3036.rs b/src/test/ui/parser/issue-3036.rs
index 00b241b9054..6a8b67fefa7 100644
--- a/src/test/ui/parser/issue-3036.rs
+++ b/src/test/ui/parser/issue-3036.rs
@@ -2,5 +2,5 @@
 
 fn main()
 {
-    let x = 3
-} //~ ERROR: expected one of `.`, `;`, `?`, or an operator, found `}`
+    let x = 3 //~ ERROR: expected `;`
+}
diff --git a/src/test/ui/parser/issue-3036.stderr b/src/test/ui/parser/issue-3036.stderr
index 18947b8fa40..b6557163d45 100644
--- a/src/test/ui/parser/issue-3036.stderr
+++ b/src/test/ui/parser/issue-3036.stderr
@@ -1,10 +1,10 @@
-error: expected one of `.`, `;`, `?`, or an operator, found `}`
-  --> $DIR/issue-3036.rs:6:1
+error: expected `;`, found ``}``
+  --> $DIR/issue-3036.rs:5:14
    |
 LL |     let x = 3
-   |              - expected one of `.`, `;`, `?`, or an operator here
+   |              ^ help: add `;` here
 LL | }
-   | ^ unexpected token
+   | - unexpected token
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/parser/macro/trait-non-item-macros.stderr b/src/test/ui/parser/macro/trait-non-item-macros.stderr
index 76670e0bde0..a953e23a710 100644
--- a/src/test/ui/parser/macro/trait-non-item-macros.stderr
+++ b/src/test/ui/parser/macro/trait-non-item-macros.stderr
@@ -2,7 +2,7 @@ error: expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, fo
   --> $DIR/trait-non-item-macros.rs:2:19
    |
 LL |     ($a:expr) => ($a)
-   |                   ^^ unexpected token
+   |                   ^^ expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe` here
 ...
 LL |     bah!(2);
    |     -------- in this macro invocation
diff --git a/src/test/ui/parser/raw/raw-literal-keywords.rs b/src/test/ui/parser/raw/raw-literal-keywords.rs
index 6b055fbb117..bf9cbcdab2e 100644
--- a/src/test/ui/parser/raw/raw-literal-keywords.rs
+++ b/src/test/ui/parser/raw/raw-literal-keywords.rs
@@ -1,5 +1,5 @@
 fn test_if() {
-    r#if true { } //~ ERROR found `true`
+    r#if true { } //~ ERROR found keyword `true`
 }
 
 fn test_struct() {
diff --git a/src/test/ui/parser/raw/raw-literal-keywords.stderr b/src/test/ui/parser/raw/raw-literal-keywords.stderr
index f39e29cfaa8..4cea605be6f 100644
--- a/src/test/ui/parser/raw/raw-literal-keywords.stderr
+++ b/src/test/ui/parser/raw/raw-literal-keywords.stderr
@@ -1,4 +1,4 @@
-error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `true`
+error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found keyword `true`
   --> $DIR/raw-literal-keywords.rs:2:10
    |
 LL |     r#if true { }
diff --git a/src/test/ui/parser/recover-for-loop-parens-around-head.rs b/src/test/ui/parser/recover-for-loop-parens-around-head.rs
index c6be2c90667..779e1646344 100644
--- a/src/test/ui/parser/recover-for-loop-parens-around-head.rs
+++ b/src/test/ui/parser/recover-for-loop-parens-around-head.rs
@@ -8,7 +8,7 @@ fn main() {
     let vec = vec![1, 2, 3];
 
     for ( elem in vec ) {
-        //~^ ERROR expected one of `)`, `,`, `@`, or `|`, found `in`
+        //~^ ERROR expected one of `)`, `,`, `@`, or `|`, found keyword `in`
         //~| ERROR unexpected closing `)`
         const RECOVERY_WITNESS: () = 0; //~ ERROR mismatched types
     }
diff --git a/src/test/ui/parser/recover-for-loop-parens-around-head.stderr b/src/test/ui/parser/recover-for-loop-parens-around-head.stderr
index 1b5b6cca092..1a1f395ee21 100644
--- a/src/test/ui/parser/recover-for-loop-parens-around-head.stderr
+++ b/src/test/ui/parser/recover-for-loop-parens-around-head.stderr
@@ -1,4 +1,4 @@
-error: expected one of `)`, `,`, `@`, or `|`, found `in`
+error: expected one of `)`, `,`, `@`, or `|`, found keyword `in`
   --> $DIR/recover-for-loop-parens-around-head.rs:10:16
    |
 LL |     for ( elem in vec ) {
diff --git a/src/test/ui/parser/recover-missing-semi.rs b/src/test/ui/parser/recover-missing-semi.rs
index 1893dc716be..f47d5e6805f 100644
--- a/src/test/ui/parser/recover-missing-semi.rs
+++ b/src/test/ui/parser/recover-missing-semi.rs
@@ -1,13 +1,13 @@
 fn main() {
     let _: usize = ()
     //~^ ERROR mismatched types
+    //~| ERROR expected `;`
     let _ = 3;
-    //~^ ERROR expected one of
 }
 
 fn foo() -> usize {
     let _: usize = ()
     //~^ ERROR mismatched types
+    //~| ERROR expected `;`
     return 3;
-    //~^ ERROR expected one of
 }
diff --git a/src/test/ui/parser/recover-missing-semi.stderr b/src/test/ui/parser/recover-missing-semi.stderr
index 99339e4dd50..c40918ee2bd 100644
--- a/src/test/ui/parser/recover-missing-semi.stderr
+++ b/src/test/ui/parser/recover-missing-semi.stderr
@@ -1,20 +1,20 @@
-error: expected one of `.`, `;`, `?`, or an operator, found `let`
-  --> $DIR/recover-missing-semi.rs:4:5
+error: expected `;`, found `keyword `let``
+  --> $DIR/recover-missing-semi.rs:2:22
    |
 LL |     let _: usize = ()
-   |                      - help: a semicolon may be missing here
-LL |
+   |                      ^ help: add `;` here
+...
 LL |     let _ = 3;
-   |     ^^^
+   |     --- unexpected token
 
-error: expected one of `.`, `;`, `?`, or an operator, found `return`
-  --> $DIR/recover-missing-semi.rs:11:5
+error: expected `;`, found `keyword `return``
+  --> $DIR/recover-missing-semi.rs:9:22
    |
 LL |     let _: usize = ()
-   |                      - help: a semicolon may be missing here
-LL |
+   |                      ^ help: add `;` here
+...
 LL |     return 3;
-   |     ^^^^^^
+   |     ------ unexpected token
 
 error[E0308]: mismatched types
   --> $DIR/recover-missing-semi.rs:2:20
diff --git a/src/test/ui/parser/removed-syntax-static-fn.stderr b/src/test/ui/parser/removed-syntax-static-fn.stderr
index 21cb71df657..af148e69711 100644
--- a/src/test/ui/parser/removed-syntax-static-fn.stderr
+++ b/src/test/ui/parser/removed-syntax-static-fn.stderr
@@ -1,4 +1,4 @@
-error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `static`
+error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found keyword `static`
   --> $DIR/removed-syntax-static-fn.rs:4:5
    |
 LL | impl S {
diff --git a/src/test/ui/parser/removed-syntax-uniq-mut-ty.rs b/src/test/ui/parser/removed-syntax-uniq-mut-ty.rs
index 79d51f5595d..f9a9d071a3d 100644
--- a/src/test/ui/parser/removed-syntax-uniq-mut-ty.rs
+++ b/src/test/ui/parser/removed-syntax-uniq-mut-ty.rs
@@ -1 +1,2 @@
-type mut_box = Box<mut isize>; //~ ERROR expected one of `>`, const, lifetime, or type, found `mut`
+type mut_box = Box<mut isize>;
+//~^ ERROR expected one of `>`, const, lifetime, or type, found keyword `mut`
diff --git a/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr b/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr
index b6c5749c031..9c47e3db67d 100644
--- a/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr
+++ b/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr
@@ -1,4 +1,4 @@
-error: expected one of `>`, const, lifetime, or type, found `mut`
+error: expected one of `>`, const, lifetime, or type, found keyword `mut`
   --> $DIR/removed-syntax-uniq-mut-ty.rs:1:20
    |
 LL | type mut_box = Box<mut isize>;
diff --git a/src/test/ui/parser/underscore_item_not_const.rs b/src/test/ui/parser/underscore_item_not_const.rs
index 375bdc3a463..7b0d128f06f 100644
--- a/src/test/ui/parser/underscore_item_not_const.rs
+++ b/src/test/ui/parser/underscore_item_not_const.rs
@@ -25,6 +25,6 @@ use _ as g; //~ ERROR expected identifier, found reserved identifier `_`
 trait _ {} //~ ERROR expected identifier, found reserved identifier `_`
 trait _ = Copy; //~ ERROR expected identifier, found reserved identifier `_`
 macro_rules! _ { () => {} } //~ ERROR expected identifier, found reserved identifier `_`
-union _ { f: u8 } //~ ERROR expected one of `!` or `::`, found `_`
+union _ { f: u8 } //~ ERROR expected one of `!` or `::`, found reserved identifier `_`
 
 fn main() {}
diff --git a/src/test/ui/parser/underscore_item_not_const.stderr b/src/test/ui/parser/underscore_item_not_const.stderr
index deb4a012e32..8814aa35271 100644
--- a/src/test/ui/parser/underscore_item_not_const.stderr
+++ b/src/test/ui/parser/underscore_item_not_const.stderr
@@ -82,7 +82,7 @@ error: expected identifier, found reserved identifier `_`
 LL | macro_rules! _ { () => {} }
    |              ^ expected identifier, found reserved identifier
 
-error: expected one of `!` or `::`, found `_`
+error: expected one of `!` or `::`, found reserved identifier `_`
   --> $DIR/underscore_item_not_const.rs:28:7
    |
 LL | union _ { f: u8 }