about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2018-06-30 11:02:38 +0100
committerMatthew Jasper <mjjasper1@gmail.com>2018-06-30 11:02:38 +0100
commitc613aa5a95a83ec77b4b0af1e74019cb8aca75b4 (patch)
tree5d885f5d679f7b02df019b96c49a769ff6da24df /src/test
parent5fdcd3aa389aa92879f576c55e429015667143c3 (diff)
downloadrust-c613aa5a95a83ec77b4b0af1e74019cb8aca75b4.tar.gz
rust-c613aa5a95a83ec77b4b0af1e74019cb8aca75b4.zip
Improve error messages when assigning to a local that starts initialized
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/immut-function-arguments.rs4
-rw-r--r--src/test/ui/command-line-diagnostics.nll.stderr3
-rw-r--r--src/test/ui/did_you_mean/issue-35937.nll.stderr14
3 files changed, 10 insertions, 11 deletions
diff --git a/src/test/compile-fail/immut-function-arguments.rs b/src/test/compile-fail/immut-function-arguments.rs
index b32056fcb91..61a074952ef 100644
--- a/src/test/compile-fail/immut-function-arguments.rs
+++ b/src/test/compile-fail/immut-function-arguments.rs
@@ -13,12 +13,12 @@
 
 fn f(y: Box<isize>) {
     *y = 5; //[ast]~ ERROR cannot assign
-            //[mir]~^ ERROR cannot assign twice
+            //[mir]~^ ERROR cannot assign
 }
 
 fn g() {
     let _frob = |q: Box<isize>| { *q = 2; }; //[ast]~ ERROR cannot assign
-    //[mir]~^ ERROR cannot assign twice
+    //[mir]~^ ERROR cannot assign
 }
 
 fn main() {}
diff --git a/src/test/ui/command-line-diagnostics.nll.stderr b/src/test/ui/command-line-diagnostics.nll.stderr
index 10dcf7d0e65..46bb7c5af57 100644
--- a/src/test/ui/command-line-diagnostics.nll.stderr
+++ b/src/test/ui/command-line-diagnostics.nll.stderr
@@ -2,8 +2,9 @@ error[E0384]: cannot assign twice to immutable variable `x`
   --> $DIR/command-line-diagnostics.rs:16:5
    |
 LL |     let x = 42;
-   |         -   -- first assignment to `x`
+   |         -
    |         |
+   |         first assignment to `x`
    |         consider changing this to `mut x`
 LL |     x = 43;
    |     ^^^^^^ cannot assign twice to immutable variable
diff --git a/src/test/ui/did_you_mean/issue-35937.nll.stderr b/src/test/ui/did_you_mean/issue-35937.nll.stderr
index 0c1dcb29d4d..7eaa4c7d5fe 100644
--- a/src/test/ui/did_you_mean/issue-35937.nll.stderr
+++ b/src/test/ui/did_you_mean/issue-35937.nll.stderr
@@ -6,26 +6,24 @@ LL |     let f = Foo { v: Vec::new() };
 LL |     f.v.push("cat".to_string()); //~ ERROR cannot borrow
    |     ^^^ cannot borrow as mutable
 
-error[E0384]: cannot assign twice to immutable variable `s.x`
+error[E0384]: cannot assign twice to immutable variable `s`
   --> $DIR/issue-35937.rs:26:5
    |
 LL |     let s = S { x: 42 };
-   |         -   ----------- first assignment to `s.x`
+   |         -
    |         |
+   |         first assignment to `s`
    |         consider changing this to `mut s`
 LL |     s.x += 1; //~ ERROR cannot assign
    |     ^^^^^^^^ cannot assign twice to immutable variable
 
-error[E0384]: cannot assign twice to immutable variable `s.x`
+error[E0384]: cannot assign to immutable argument `s`
   --> $DIR/issue-35937.rs:30:5
    |
 LL | fn bar(s: S) {
-   |        -
-   |        |
-   |        first assignment to `s.x`
-   |        consider changing this to `mut s`
+   |        - consider changing this to `mut s`
 LL |     s.x += 1; //~ ERROR cannot assign
-   |     ^^^^^^^^ cannot assign twice to immutable variable
+   |     ^^^^^^^^ cannot assign to immutable argument
 
 error: aborting due to 3 previous errors