From 0e8ec4333c969bfa81231e54aa6e8ef203e87987 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20manuel=20Barroso=20Galindo?=
 <theypsilon@gmail.com>
Date: Wed, 10 Aug 2016 00:07:42 +0700
Subject: [PATCH] Update error message E0384 to new format

Part of #35233
Fixes #35184
---
 src/librustc_borrowck/borrowck/mod.rs                | 12 ++++++++----
 src/test/compile-fail/asm-out-assign-imm.rs          |  3 ++-
 src/test/compile-fail/assign-imm-local-twice.rs      |  3 ++-
 .../liveness-assign-imm-local-in-loop.rs             |  2 +-
 .../liveness-assign-imm-local-in-op-eq.rs            |  3 ++-
 .../liveness-assign-imm-local-with-init.rs           |  3 ++-
 6 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs
index 9115fd42be8..4c120dd7ab7 100644
--- a/src/librustc_borrowck/borrowck/mod.rs
+++ b/src/librustc_borrowck/borrowck/mod.rs
@@ -758,12 +758,16 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
                                                 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) {
diff --git a/src/test/compile-fail/asm-out-assign-imm.rs b/src/test/compile-fail/asm-out-assign-imm.rs
index c1c72a5519b..0541faa0213 100644
--- a/src/test/compile-fail/asm-out-assign-imm.rs
+++ b/src/test/compile-fail/asm-out-assign-imm.rs
@@ -18,11 +18,12 @@ fn foo(x: isize) { println!("{}", x); }
           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);
diff --git a/src/test/compile-fail/assign-imm-local-twice.rs b/src/test/compile-fail/assign-imm-local-twice.rs
index 540272a8e2c..9a5d6289b58 100644
--- a/src/test/compile-fail/assign-imm-local-twice.rs
+++ b/src/test/compile-fail/assign-imm-local-twice.rs
@@ -10,9 +10,10 @@
 
 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);
 }
 
diff --git a/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs b/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs
index f50a9345106..9d246f8ea5e 100644
--- a/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs
+++ b/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs
@@ -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
     }
 }
diff --git a/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs b/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs
index df57bb9e441..e1eb3246137 100644
--- a/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs
+++ b/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs
@@ -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();
 }
 
diff --git a/src/test/compile-fail/liveness-assign-imm-local-with-init.rs b/src/test/compile-fail/liveness-assign-imm-local-with-init.rs
index 28218bff60d..2468c91f34b 100644
--- a/src/test/compile-fail/liveness-assign-imm-local-with-init.rs
+++ b/src/test/compile-fail/liveness-assign-imm-local-with-init.rs
@@ -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();
 }