about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs2
-rw-r--r--src/test/ui/parser/increment-autofix.fixed33
-rw-r--r--src/test/ui/parser/increment-autofix.rs43
-rw-r--r--src/test/ui/parser/increment-autofix.stderr73
-rw-r--r--src/test/ui/parser/increment-notfixed.rs34
-rw-r--r--src/test/ui/parser/increment-notfixed.stderr64
6 files changed, 135 insertions, 114 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index 0e0954d6ee2..bab4ac9d08a 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -1326,7 +1326,7 @@ impl<'a> Parser<'a> {
                 MultiSugg::emit_many(
                     &mut err,
                     "use `+= 1` instead",
-                    Applicability::MaybeIncorrect,
+                    Applicability::Unspecified,
                     [sugg1, sugg2].into_iter(),
                 )
             }
diff --git a/src/test/ui/parser/increment-autofix.fixed b/src/test/ui/parser/increment-autofix.fixed
index ad61c4e66d2..24a5ac42ca6 100644
--- a/src/test/ui/parser/increment-autofix.fixed
+++ b/src/test/ui/parser/increment-autofix.fixed
@@ -1,19 +1,5 @@
 // run-rustfix
 
-fn post_regular() {
-    let mut i = 0;
-    { let tmp = i; i += 1; tmp }; //~ ERROR Rust has no postfix increment operator
-    println!("{}", i);
-}
-
-fn post_while() {
-    let mut i = 0;
-    while { let tmp = i; i += 1; tmp } < 5 {
-        //~^ ERROR Rust has no postfix increment operator
-        println!("{}", i);
-    }
-}
-
 fn pre_regular() {
     let mut i = 0;
     i += 1; //~ ERROR Rust has no prefix increment operator
@@ -28,9 +14,18 @@ fn pre_while() {
     }
 }
 
-fn main() {
-    post_regular();
-    post_while();
-    pre_regular();
-    pre_while();
+fn pre_regular_tmp() {
+    let mut tmp = 0;
+    tmp += 1; //~ ERROR Rust has no prefix increment operator
+    println!("{}", tmp);
 }
+
+fn pre_while_tmp() {
+    let mut tmp = 0;
+    while { tmp += 1; tmp } < 5 {
+        //~^ ERROR Rust has no prefix increment operator
+        println!("{}", tmp);
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/parser/increment-autofix.rs b/src/test/ui/parser/increment-autofix.rs
index 909c8f8c371..b1cfd09e9ec 100644
--- a/src/test/ui/parser/increment-autofix.rs
+++ b/src/test/ui/parser/increment-autofix.rs
@@ -1,52 +1,31 @@
 // run-rustfix
 
-fn post_regular() {
+fn pre_regular() {
     let mut i = 0;
-    i++; //~ ERROR Rust has no postfix increment operator
+    ++i; //~ ERROR Rust has no prefix increment operator
     println!("{}", i);
 }
 
-fn post_while() {
+fn pre_while() {
     let mut i = 0;
-    while i++ < 5 {
-        //~^ ERROR Rust has no postfix increment operator
+    while ++i < 5 {
+        //~^ ERROR Rust has no prefix increment operator
         println!("{}", i);
     }
 }
 
-fn post_regular_tmp() {
+fn pre_regular_tmp() {
     let mut tmp = 0;
-    tmp++; //~ ERROR Rust has no postfix increment operator
+    ++tmp; //~ ERROR Rust has no prefix increment operator
     println!("{}", tmp);
 }
 
-fn post_while_tmp() {
+fn pre_while_tmp() {
     let mut tmp = 0;
-    while tmp++ < 5 {
-        //~^ ERROR Rust has no postfix increment operator
-        println!("{}", tmp);
-    }
-}
-
-fn pre_regular() {
-    let mut i = 0;
-    ++i; //~ ERROR Rust has no prefix increment operator
-    println!("{}", i);
-}
-
-fn pre_while() {
-    let mut i = 0;
-    while ++i < 5 {
+    while ++tmp < 5 {
         //~^ ERROR Rust has no prefix increment operator
-        println!("{}", i);
+        println!("{}", tmp);
     }
 }
 
-fn main() {
-    post_regular();
-    post_while();
-    post_regular_tmp();
-    post_while_tmp();
-    pre_regular();
-    pre_while();
-}
+fn main() {}
diff --git a/src/test/ui/parser/increment-autofix.stderr b/src/test/ui/parser/increment-autofix.stderr
index 5bf4b2751de..a9dc70ad0d6 100644
--- a/src/test/ui/parser/increment-autofix.stderr
+++ b/src/test/ui/parser/increment-autofix.stderr
@@ -1,81 +1,48 @@
-error: Rust has no postfix increment operator
-  --> $DIR/increment-autofix.rs:5:6
+error: Rust has no prefix increment operator
+  --> $DIR/increment-autofix.rs:5:5
    |
-LL |     i++;
-   |      ^^ not a valid postfix operator
+LL |     ++i;
+   |     ^^ not a valid prefix operator
    |
 help: use `+= 1` instead
    |
-LL |     { let tmp = i; i += 1; tmp };
-   |     +++++++++++  ~~~~~~~~~~~~~~~
-LL -     i++;
+LL -     ++i;
 LL +     i += 1;
    | 
 
-error: Rust has no postfix increment operator
-  --> $DIR/increment-autofix.rs:11:12
-   |
-LL |     while i++ < 5 {
-   |            ^^ not a valid postfix operator
-   |
-help: use `+= 1` instead
-   |
-LL |     while { let tmp = i; i += 1; tmp } < 5 {
-   |           +++++++++++  ~~~~~~~~~~~~~~~
-LL -     while i++ < 5 {
-LL +     while i += 1 < 5 {
-   | 
-
-error: Rust has no postfix increment operator
-  --> $DIR/increment-autofix.rs:19:8
-   |
-LL |     tmp++;
-   |        ^^ not a valid postfix operator
-   |
-help: use `+= 1` instead
-   |
-LL |     { let tmp_ = tmp; tmp += 1; tmp_ };
-   |     ++++++++++++    ~~~~~~~~~~~~~~~~~~
-LL -     tmp++;
-LL +     tmp += 1;
-   | 
-
-error: Rust has no postfix increment operator
-  --> $DIR/increment-autofix.rs:25:14
+error: Rust has no prefix increment operator
+  --> $DIR/increment-autofix.rs:11:11
    |
-LL |     while tmp++ < 5 {
-   |              ^^ not a valid postfix operator
+LL |     while ++i < 5 {
+   |           ^^ not a valid prefix operator
    |
 help: use `+= 1` instead
    |
-LL |     while { let tmp_ = tmp; tmp += 1; tmp_ } < 5 {
-   |           ++++++++++++    ~~~~~~~~~~~~~~~~~~
-LL -     while tmp++ < 5 {
-LL +     while tmp += 1 < 5 {
-   | 
+LL |     while { i += 1; i } < 5 {
+   |           ~   +++++++++
 
 error: Rust has no prefix increment operator
-  --> $DIR/increment-autofix.rs:33:5
+  --> $DIR/increment-autofix.rs:19:5
    |
-LL |     ++i;
+LL |     ++tmp;
    |     ^^ not a valid prefix operator
    |
 help: use `+= 1` instead
    |
-LL -     ++i;
-LL +     i += 1;
+LL -     ++tmp;
+LL +     tmp += 1;
    | 
 
 error: Rust has no prefix increment operator
-  --> $DIR/increment-autofix.rs:39:11
+  --> $DIR/increment-autofix.rs:25:11
    |
-LL |     while ++i < 5 {
+LL |     while ++tmp < 5 {
    |           ^^ not a valid prefix operator
    |
 help: use `+= 1` instead
    |
-LL |     while { i += 1; i } < 5 {
-   |           ~   +++++++++
+LL |     while { tmp += 1; tmp } < 5 {
+   |           ~     +++++++++++
 
-error: aborting due to 6 previous errors
+error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/parser/increment-notfixed.rs b/src/test/ui/parser/increment-notfixed.rs
index 3db8a4c3326..543f73bf772 100644
--- a/src/test/ui/parser/increment-notfixed.rs
+++ b/src/test/ui/parser/increment-notfixed.rs
@@ -6,6 +6,34 @@ struct Bar {
     qux: i32,
 }
 
+fn post_regular() {
+    let mut i = 0;
+    i++; //~ ERROR Rust has no postfix increment operator
+    println!("{}", i);
+}
+
+fn post_while() {
+    let mut i = 0;
+    while i++ < 5 {
+        //~^ ERROR Rust has no postfix increment operator
+        println!("{}", i);
+    }
+}
+
+fn post_regular_tmp() {
+    let mut tmp = 0;
+    tmp++; //~ ERROR Rust has no postfix increment operator
+    println!("{}", tmp);
+}
+
+fn post_while_tmp() {
+    let mut tmp = 0;
+    while tmp++ < 5 {
+        //~^ ERROR Rust has no postfix increment operator
+        println!("{}", tmp);
+    }
+}
+
 fn post_field() {
     let foo = Foo { bar: Bar { qux: 0 } };
     foo.bar.qux++;
@@ -30,8 +58,4 @@ fn pre_field() {
     println!("{}", foo.bar.qux);
 }
 
-fn main() {
-    post_field();
-    post_field_tmp();
-    pre_field();
-}
+fn main() {}
diff --git a/src/test/ui/parser/increment-notfixed.stderr b/src/test/ui/parser/increment-notfixed.stderr
index 16ff42ca8b0..75fce91c6ef 100644
--- a/src/test/ui/parser/increment-notfixed.stderr
+++ b/src/test/ui/parser/increment-notfixed.stderr
@@ -1,5 +1,61 @@
 error: Rust has no postfix increment operator
-  --> $DIR/increment-notfixed.rs:11:16
+  --> $DIR/increment-notfixed.rs:11:6
+   |
+LL |     i++;
+   |      ^^ not a valid postfix operator
+   |
+help: use `+= 1` instead
+   |
+LL |     { let tmp = i; i += 1; tmp };
+   |     +++++++++++  ~~~~~~~~~~~~~~~
+LL -     i++;
+LL +     i += 1;
+   | 
+
+error: Rust has no postfix increment operator
+  --> $DIR/increment-notfixed.rs:17:12
+   |
+LL |     while i++ < 5 {
+   |            ^^ not a valid postfix operator
+   |
+help: use `+= 1` instead
+   |
+LL |     while { let tmp = i; i += 1; tmp } < 5 {
+   |           +++++++++++  ~~~~~~~~~~~~~~~
+LL -     while i++ < 5 {
+LL +     while i += 1 < 5 {
+   | 
+
+error: Rust has no postfix increment operator
+  --> $DIR/increment-notfixed.rs:25:8
+   |
+LL |     tmp++;
+   |        ^^ not a valid postfix operator
+   |
+help: use `+= 1` instead
+   |
+LL |     { let tmp_ = tmp; tmp += 1; tmp_ };
+   |     ++++++++++++    ~~~~~~~~~~~~~~~~~~
+LL -     tmp++;
+LL +     tmp += 1;
+   | 
+
+error: Rust has no postfix increment operator
+  --> $DIR/increment-notfixed.rs:31:14
+   |
+LL |     while tmp++ < 5 {
+   |              ^^ not a valid postfix operator
+   |
+help: use `+= 1` instead
+   |
+LL |     while { let tmp_ = tmp; tmp += 1; tmp_ } < 5 {
+   |           ++++++++++++    ~~~~~~~~~~~~~~~~~~
+LL -     while tmp++ < 5 {
+LL +     while tmp += 1 < 5 {
+   | 
+
+error: Rust has no postfix increment operator
+  --> $DIR/increment-notfixed.rs:39:16
    |
 LL |     foo.bar.qux++;
    |                ^^ not a valid postfix operator
@@ -13,7 +69,7 @@ LL +     foo.bar.qux += 1;
    | 
 
 error: Rust has no postfix increment operator
-  --> $DIR/increment-notfixed.rs:21:10
+  --> $DIR/increment-notfixed.rs:49:10
    |
 LL |     s.tmp++;
    |          ^^ not a valid postfix operator
@@ -27,7 +83,7 @@ LL +     s.tmp += 1;
    | 
 
 error: Rust has no prefix increment operator
-  --> $DIR/increment-notfixed.rs:28:5
+  --> $DIR/increment-notfixed.rs:56:5
    |
 LL |     ++foo.bar.qux;
    |     ^^ not a valid prefix operator
@@ -38,5 +94,5 @@ LL -     ++foo.bar.qux;
 LL +     foo.bar.qux += 1;
    | 
 
-error: aborting due to 3 previous errors
+error: aborting due to 7 previous errors