Reword to avoid using either re-assignment or reassignment in errors

This commit is contained in:
Carol (Nichols || Goulding) 2017-10-25 11:29:14 -04:00
parent b2478052f8
commit 0e46cf4db4
10 changed files with 21 additions and 21 deletions

View File

@ -744,7 +744,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
let mut err = self.cannot_reassign_immutable(span, let mut err = self.cannot_reassign_immutable(span,
&self.loan_path_to_string(lp), &self.loan_path_to_string(lp),
Origin::Ast); Origin::Ast);
err.span_label(span, "re-assignment of immutable variable"); err.span_label(span, "cannot assign twice to immutable variable");
if span != assign.span { if span != assign.span {
err.span_label(assign.span, format!("first assignment to `{}`", err.span_label(assign.span, format!("first assignment to `{}`",
self.loan_path_to_string(lp))); self.loan_path_to_string(lp)));

View File

@ -1161,7 +1161,7 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx>
self.tcx.cannot_reassign_immutable(span, self.tcx.cannot_reassign_immutable(span,
&self.describe_lvalue(lvalue), &self.describe_lvalue(lvalue),
Origin::Mir) Origin::Mir)
.span_label(span, "re-assignment of immutable variable") .span_label(span, "cannot assign twice to immutable variable")
.span_label(assigned_span, format!("first assignment to `{}`", .span_label(assigned_span, format!("first assignment to `{}`",
self.describe_lvalue(lvalue))) self.describe_lvalue(lvalue)))
.emit(); .emit();

View File

@ -232,7 +232,7 @@ pub trait BorrowckErrors {
-> DiagnosticBuilder -> DiagnosticBuilder
{ {
struct_span_err!(self, span, E0384, struct_span_err!(self, span, E0384,
"re-assignment of immutable variable `{}`{OGN}", "cannot assign twice to immutable variable `{}`{OGN}",
desc, OGN=o) desc, OGN=o)
} }

View File

@ -27,8 +27,8 @@ pub fn main() {
foo(x); foo(x);
unsafe { unsafe {
asm!("mov $1, $0" : "=r"(x) : "r"(5)); asm!("mov $1, $0" : "=r"(x) : "r"(5));
//~^ ERROR re-assignment of immutable variable `x` //~^ ERROR cannot assign twice to immutable variable `x`
//~| NOTE re-assignment of immutable //~| NOTE cannot assign twice to immutable
} }
foo(x); foo(x);
} }

View File

@ -12,8 +12,8 @@ fn test() {
let v: isize; let v: isize;
v = 1; //~ NOTE first assignment v = 1; //~ NOTE first assignment
println!("v={}", v); println!("v={}", v);
v = 2; //~ ERROR re-assignment of immutable variable v = 2; //~ ERROR cannot assign twice to immutable variable
//~| NOTE re-assignment of immutable //~| NOTE cannot assign twice to immutable
println!("v={}", v); println!("v={}", v);
} }

View File

@ -26,7 +26,7 @@ struct S {
pub fn main() { pub fn main() {
match 1 { match 1 {
x => { x => {
x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
//[mir]~^ ERROR (Mir) [E0384] //[mir]~^ ERROR (Mir) [E0384]
//[mir]~| ERROR (Ast) [E0384] //[mir]~| ERROR (Ast) [E0384]
} }
@ -34,7 +34,7 @@ pub fn main() {
match E::Foo(1) { match E::Foo(1) {
E::Foo(x) => { E::Foo(x) => {
x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
//[mir]~^ ERROR (Mir) [E0384] //[mir]~^ ERROR (Mir) [E0384]
//[mir]~| ERROR (Ast) [E0384] //[mir]~| ERROR (Ast) [E0384]
} }
@ -42,7 +42,7 @@ pub fn main() {
match (S { bar: 1 }) { match (S { bar: 1 }) {
S { bar: x } => { S { bar: x } => {
x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
//[mir]~^ ERROR (Mir) [E0384] //[mir]~^ ERROR (Mir) [E0384]
//[mir]~| ERROR (Ast) [E0384] //[mir]~| ERROR (Ast) [E0384]
} }
@ -50,7 +50,7 @@ pub fn main() {
match (1,) { match (1,) {
(x,) => { (x,) => {
x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
//[mir]~^ ERROR (Mir) [E0384] //[mir]~^ ERROR (Mir) [E0384]
//[mir]~| ERROR (Ast) [E0384] //[mir]~| ERROR (Ast) [E0384]
} }
@ -58,7 +58,7 @@ pub fn main() {
match [1,2,3] { match [1,2,3] {
[x,_,_] => { [x,_,_] => {
x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
//[mir]~^ ERROR (Mir) [E0384] //[mir]~^ ERROR (Mir) [E0384]
//[mir]~| ERROR (Ast) [E0384] //[mir]~| ERROR (Ast) [E0384]
} }

View File

@ -11,8 +11,8 @@
fn test() { fn test() {
let v: isize; let v: isize;
loop { loop {
v = 1; //~ ERROR re-assignment of immutable variable v = 1; //~ ERROR cannot assign twice to immutable variable
//~^ NOTE re-assignment of immutable variable //~^ NOTE cannot assign twice to immutable variable
v.clone(); // just to prevent liveness warnings v.clone(); // just to prevent liveness warnings
} }
} }

View File

@ -11,8 +11,8 @@
fn test() { fn test() {
let v: isize; let v: isize;
v = 2; //~ NOTE first assignment v = 2; //~ NOTE first assignment
v += 1; //~ ERROR re-assignment of immutable variable v += 1; //~ ERROR cannot assign twice to immutable variable
//~| NOTE re-assignment of immutable //~| NOTE cannot assign twice to immutable
v.clone(); v.clone();
} }

View File

@ -11,8 +11,8 @@
fn test() { fn test() {
let v: isize = 1; //~ NOTE first assignment let v: isize = 1; //~ NOTE first assignment
v.clone(); v.clone();
v = 2; //~ ERROR re-assignment of immutable variable v = 2; //~ ERROR cannot assign twice to immutable variable
//~| NOTE re-assignment of immutable //~| NOTE cannot assign twice to immutable
v.clone(); v.clone();
} }

View File

@ -15,9 +15,9 @@ fn main() {
let foo = &mut 1; let foo = &mut 1;
let &mut x = foo; let &mut x = foo;
x += 1; //[ast]~ ERROR re-assignment of immutable variable x += 1; //[ast]~ ERROR cannot assign twice to immutable variable
//[mir]~^ ERROR re-assignment of immutable variable `x` (Ast) //[mir]~^ ERROR cannot assign twice to immutable variable `x` (Ast)
//[mir]~| ERROR re-assignment of immutable variable `x` (Mir) //[mir]~| ERROR cannot assign twice to immutable variable `x` (Mir)
// explicitly mut-ify internals // explicitly mut-ify internals
let &mut mut x = foo; let &mut mut x = foo;