about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-12-03 18:08:19 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2019-12-20 22:53:40 +0100
commitc9e1f13f6eb9d21224c083eb07d894adffc7ec96 (patch)
treeb78472f4650714a67fc3ccbe745982a9a9645394 /src/test/ui/parser
parenta0d20935cc7dc9057c683bb62a4ba74475f32aa2 (diff)
downloadrust-c9e1f13f6eb9d21224c083eb07d894adffc7ec96.tar.gz
rust-c9e1f13f6eb9d21224c083eb07d894adffc7ec96.zip
recover on 'mut', 'var', 'auto'
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/issue-65257-invalid-var-decl-recovery.rs21
-rw-r--r--src/test/ui/parser/issue-65257-invalid-var-decl-recovery.stderr59
2 files changed, 80 insertions, 0 deletions
diff --git a/src/test/ui/parser/issue-65257-invalid-var-decl-recovery.rs b/src/test/ui/parser/issue-65257-invalid-var-decl-recovery.rs
new file mode 100644
index 00000000000..7efc4174874
--- /dev/null
+++ b/src/test/ui/parser/issue-65257-invalid-var-decl-recovery.rs
@@ -0,0 +1,21 @@
+fn main() {
+    auto n = 0;//~ ERROR invalid variable declaration
+    //~^ HELP to introduce a variable, write `let` instead of `auto`
+    auto m;//~ ERROR invalid variable declaration
+    //~^ HELP to introduce a variable, write `let` instead of `auto`
+    m = 0;
+
+    var n = 0;//~ ERROR invalid variable declaration
+    //~^ HELP to introduce a variable, write `let` instead of `var`
+    var m;//~ ERROR invalid variable declaration
+    //~^ HELP to introduce a variable, write `let` instead of `var`
+    m = 0;
+
+    mut n = 0;//~ ERROR invalid variable declaration
+    //~^ HELP missing `let`
+    mut var;//~ ERROR invalid variable declaration
+    //~^ HELP missing `let`
+    var = 0;
+
+    let _recovery_witness: () = 0; //~ ERROR mismatched types
+}
diff --git a/src/test/ui/parser/issue-65257-invalid-var-decl-recovery.stderr b/src/test/ui/parser/issue-65257-invalid-var-decl-recovery.stderr
new file mode 100644
index 00000000000..429c12265bd
--- /dev/null
+++ b/src/test/ui/parser/issue-65257-invalid-var-decl-recovery.stderr
@@ -0,0 +1,59 @@
+error: invalid variable declaration
+  --> $DIR/issue-65257-invalid-var-decl-recovery.rs:2:5
+   |
+LL |     auto n = 0;
+   |     ----^^^^^^
+   |     |
+   |     help: to introduce a variable, write `let` instead of `auto`
+
+error: invalid variable declaration
+  --> $DIR/issue-65257-invalid-var-decl-recovery.rs:4:5
+   |
+LL |     auto m;
+   |     ----^^
+   |     |
+   |     help: to introduce a variable, write `let` instead of `auto`
+
+error: invalid variable declaration
+  --> $DIR/issue-65257-invalid-var-decl-recovery.rs:8:5
+   |
+LL |     var n = 0;
+   |     ---^^^^^^
+   |     |
+   |     help: to introduce a variable, write `let` instead of `var`
+
+error: invalid variable declaration
+  --> $DIR/issue-65257-invalid-var-decl-recovery.rs:10:5
+   |
+LL |     var m;
+   |     ---^^
+   |     |
+   |     help: to introduce a variable, write `let` instead of `var`
+
+error: invalid variable declaration
+  --> $DIR/issue-65257-invalid-var-decl-recovery.rs:14:5
+   |
+LL |     mut n = 0;
+   |     ---^^^^^^
+   |     |
+   |     help: missing `let`
+
+error: invalid variable declaration
+  --> $DIR/issue-65257-invalid-var-decl-recovery.rs:16:5
+   |
+LL |     mut var;
+   |     ---^^^^
+   |     |
+   |     help: missing `let`
+
+error[E0308]: mismatched types
+  --> $DIR/issue-65257-invalid-var-decl-recovery.rs:20:33
+   |
+LL |     let _recovery_witness: () = 0;
+   |                            --   ^ expected `()`, found integer
+   |                            |
+   |                            expected due to this
+
+error: aborting due to 7 previous errors
+
+For more information about this error, try `rustc --explain E0308`.