]> git.lizzy.rs Git - rust.git/commitdiff
Update error message E0384 to new format
authorJosé manuel Barroso Galindo <theypsilon@gmail.com>
Tue, 9 Aug 2016 17:07:42 +0000 (00:07 +0700)
committerJosé manuel Barroso Galindo <theypsilon@gmail.com>
Tue, 9 Aug 2016 17:07:42 +0000 (00:07 +0700)
Part of #35233
Fixes #35184

src/librustc_borrowck/borrowck/mod.rs
src/test/compile-fail/asm-out-assign-imm.rs
src/test/compile-fail/assign-imm-local-twice.rs
src/test/compile-fail/liveness-assign-imm-local-in-loop.rs
src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs
src/test/compile-fail/liveness-assign-imm-local-with-init.rs

index 9115fd42be870e02aec87792b163d02ca5657720..4c120dd7ab7f424219696d907cbc4986792c4fbf 100644 (file)
@@ -758,12 +758,16 @@ pub fn report_reassigned_immutable_variable(&self,
                                                 lp: &LoanPath<'tcx>,
                                                 assign:
                                                 &move_data::Assignment) {
-        struct_span_err!(
+        let mut err = struct_span_err!(
             self.tcx.sess, span, E0384,
             "re-assignment of immutable variable `{}`",
-            self.loan_path_to_string(lp))
-            .span_note(assign.span, "prior assignment occurs here")
-            .emit();
+            self.loan_path_to_string(lp));
+        err.span_label(span, &format!("re-assignment of immutable variable"));
+        if span != assign.span {
+            err.span_label(assign.span, &format!("first assignment to `{}`",
+                                              self.loan_path_to_string(lp)));
+        }
+        err.emit();
     }
 
     pub fn span_err(&self, s: Span, m: &str) {
index c1c72a5519bf10b5d81c389fad5481c8ee432db7..0541faa021356f0a0719423833dde86ee85b24c3 100644 (file)
           target_arch = "aarch64"))]
 pub fn main() {
     let x: isize;
-    x = 1; //~ NOTE prior assignment occurs here
+    x = 1; //~ NOTE first assignment
     foo(x);
     unsafe {
         asm!("mov $1, $0" : "=r"(x) : "r"(5));
         //~^ ERROR re-assignment of immutable variable `x`
+        //~| NOTE re-assignment of immutable
         //~| NOTE in this expansion of asm!
     }
     foo(x);
index 540272a8e2c58b511542504a666fdf20fb4be2c1..9a5d6289b589ecd3b5d556ffe3dff14b8d6b3f5c 100644 (file)
 
 fn test() {
     let v: isize;
-    v = 1; //~ NOTE prior assignment occurs here
+    v = 1; //~ NOTE first assignment
     println!("v={}", v);
     v = 2; //~ ERROR re-assignment of immutable variable
+           //~| NOTE re-assignment of immutable
     println!("v={}", v);
 }
 
index f50a934510697669557cbe2a014b13dd2570bb57..9d246f8ea5e0e5bb08f01569508b805abee44ebc 100644 (file)
@@ -12,7 +12,7 @@ fn test() {
     let v: isize;
     loop {
         v = 1; //~ ERROR re-assignment of immutable variable
-        //~^ NOTE prior assignment occurs here
+        //~^ NOTE re-assignment of immutable variable
         v.clone(); // just to prevent liveness warnings
     }
 }
index df57bb9e4417ed17e6b77c2cf027e25adcf5db7f..e1eb3246137d22a9d711d93d5dd518ff22b1dd37 100644 (file)
@@ -10,8 +10,9 @@
 
 fn test() {
     let v: isize;
-    v = 2;  //~ NOTE prior assignment occurs here
+    v = 2;  //~ NOTE first assignment
     v += 1; //~ ERROR re-assignment of immutable variable
+            //~| NOTE re-assignment of immutable
     v.clone();
 }
 
index 28218bff60d68c96051741f5c3d66b2d9c3a9bb7..2468c91f34bbd018a4c324eed5c3e924f4a28b5c 100644 (file)
@@ -9,9 +9,10 @@
 // except according to those terms.
 
 fn test() {
-    let v: isize = 1; //~ NOTE prior assignment occurs here
+    let v: isize = 1; //~ NOTE first assignment
     v.clone();
     v = 2; //~ ERROR re-assignment of immutable variable
+           //~| NOTE re-assignment of immutable
     v.clone();
 }