diff options
| author | Basile Desloges <basile.desloges@gmail.com> | 2017-11-16 16:52:04 +0100 |
|---|---|---|
| committer | Basile Desloges <basile.desloges@gmail.com> | 2017-11-19 20:19:10 +0100 |
| commit | 094d67ee37d37caa2ebd755fa39ebcaa7b586b26 (patch) | |
| tree | 9d2dd59c5c3fe648fb3cc9b838160a17442e8af1 /src | |
| parent | d8d5b6180f56e4aaddc9492b891f85f9ca4a3c64 (diff) | |
| download | rust-094d67ee37d37caa2ebd755fa39ebcaa7b586b26.tar.gz rust-094d67ee37d37caa2ebd755fa39ebcaa7b586b26.zip | |
mir-borrowck: Remove parens in the lvalue description of a deref
Diffstat (limited to 'src')
6 files changed, 14 insertions, 15 deletions
diff --git a/src/librustc_mir/borrow_check.rs b/src/librustc_mir/borrow_check.rs index cdac72b6dff..486f95f68ea 100644 --- a/src/librustc_mir/borrow_check.rs +++ b/src/librustc_mir/borrow_check.rs @@ -1601,9 +1601,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { if autoderef { self.append_lvalue_to_string(&proj.base, buf, Some(autoderef)); } else { - buf.push_str(&"(*"); + buf.push_str(&"*"); self.append_lvalue_to_string(&proj.base, buf, Some(autoderef)); - buf.push_str(&")"); } }, ProjectionElem::Downcast(..) => { diff --git a/src/test/compile-fail/borrowck/borrowck-closures-mut-and-imm.rs b/src/test/compile-fail/borrowck/borrowck-closures-mut-and-imm.rs index 0b6b9bf7d48..c40470a927c 100644 --- a/src/test/compile-fail/borrowck/borrowck-closures-mut-and-imm.rs +++ b/src/test/compile-fail/borrowck/borrowck-closures-mut-and-imm.rs @@ -70,7 +70,7 @@ fn f() { let c1 = || get(&*x); *x = 5; //[ast]~ ERROR cannot assign //[mir]~^ ERROR cannot assign to `*x` because it is borrowed (Ast) - //[mir]~| ERROR cannot assign to `(*x)` because it is borrowed (Mir) + //[mir]~| ERROR cannot assign to `*x` because it is borrowed (Mir) } fn g() { @@ -82,7 +82,7 @@ fn g() { let c1 = || get(&*x.f); *x.f = 5; //[ast]~ ERROR cannot assign to `*x.f` //[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed (Ast) - //[mir]~| ERROR cannot assign to `(*x.f)` because it is borrowed (Mir) + //[mir]~| ERROR cannot assign to `*x.f` because it is borrowed (Mir) } fn h() { diff --git a/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs b/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs index d1cf08ac754..009819f0bb5 100644 --- a/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs +++ b/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs @@ -252,7 +252,7 @@ fn main() { fn bump<'a>(mut block: &mut Block<'a>) { let x = &mut block; let p: &'a u8 = &*block.current; - //[mir]~^ ERROR cannot borrow `(*block.current)` as immutable because it is also borrowed as mutable (Mir) + //[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable (Mir) // No errors in AST because of issue rust#38899 } } @@ -266,7 +266,7 @@ fn main() { unsafe fn bump2(mut block: *mut Block2) { let x = &mut block; let p : *const u8 = &*(*block).current; - //[mir]~^ ERROR cannot borrow `(*block.current)` as immutable because it is also borrowed as mutable (Mir) + //[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable (Mir) // No errors in AST because of issue rust#38899 } } @@ -279,7 +279,7 @@ fn main() { //[ast]~^ ERROR cannot use `v[..].y` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..].y` because it was mutably borrowed (Ast) //[mir]~| ERROR cannot use `v[..].y` because it was mutably borrowed (Mir) - //[mir]~| ERROR cannot use `(*v)` because it was mutably borrowed (Mir) + //[mir]~| ERROR cannot use `*v` because it was mutably borrowed (Mir) } // Field of constant index { @@ -300,7 +300,7 @@ fn main() { let y = &mut x; &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time //[mir]~^ ERROR cannot borrow `**x` as mutable more than once at a time (Ast) - //[mir]~| ERROR cannot borrow `(*x)` as mutable more than once at a time (Mir) + //[mir]~| ERROR cannot borrow `*x` as mutable more than once at a time (Mir) *y = 1; }; } @@ -312,7 +312,7 @@ fn main() { let y = &mut x; &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time //[mir]~^ ERROR cannot borrow `**x` as mutable more than once at a time (Ast) - //[mir]~| ERROR cannot borrow `(*x)` as mutable more than once at a time (Mir) + //[mir]~| ERROR cannot borrow `*x` as mutable more than once at a time (Mir) *y = 1; } }; diff --git a/src/test/compile-fail/coerce-overloaded-autoderef.rs b/src/test/compile-fail/coerce-overloaded-autoderef.rs index 43b771ce5db..1060c3f468c 100644 --- a/src/test/compile-fail/coerce-overloaded-autoderef.rs +++ b/src/test/compile-fail/coerce-overloaded-autoderef.rs @@ -22,7 +22,7 @@ fn double_mut_borrow<T>(x: &mut Box<T>) { let z = borrow_mut(x); //[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time //[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time (Ast) - //[mir]~| ERROR cannot borrow `(*x)` as mutable more than once at a time (Mir) + //[mir]~| ERROR cannot borrow `*x` as mutable more than once at a time (Mir) } fn double_imm_borrow(x: &mut Box<i32>) { @@ -31,21 +31,21 @@ fn double_imm_borrow(x: &mut Box<i32>) { **x += 1; //[ast]~^ ERROR cannot assign to `**x` because it is borrowed //[mir]~^^ ERROR cannot assign to `**x` because it is borrowed (Ast) - //[mir]~| ERROR cannot assign to `(*(*x))` because it is borrowed (Mir) + //[mir]~| ERROR cannot assign to `**x` because it is borrowed (Mir) } fn double_mut_borrow2<T>(x: &mut Box<T>) { borrow_mut2(x, x); //[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time //[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time (Ast) - //[mir]~| ERROR cannot borrow `(*x)` as mutable more than once at a time (Mir) + //[mir]~| ERROR cannot borrow `*x` as mutable more than once at a time (Mir) } fn double_borrow2<T>(x: &mut Box<T>) { borrow2(x, x); //[ast]~^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable //[mir]~^^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable (Ast) - //[mir]~| ERROR cannot borrow `(*x)` as immutable because it is also borrowed as mutable (Mir) + //[mir]~| ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable (Mir) } pub fn main() {} diff --git a/src/test/compile-fail/mut-pattern-internal-mutability.rs b/src/test/compile-fail/mut-pattern-internal-mutability.rs index 1c7bc9d7303..a1b7a314f21 100644 --- a/src/test/compile-fail/mut-pattern-internal-mutability.rs +++ b/src/test/compile-fail/mut-pattern-internal-mutability.rs @@ -27,5 +27,5 @@ fn main() { let &mut ref x = foo; *foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed //[mir]~^ ERROR cannot assign to `*foo` because it is borrowed (Ast) - //[mir]~| ERROR cannot assign to `(*foo)` because it is borrowed (Mir) + //[mir]~| ERROR cannot assign to `*foo` because it is borrowed (Mir) } diff --git a/src/test/ui/nll/get_default.stderr b/src/test/ui/nll/get_default.stderr index 9586f426720..8e1e9faef2f 100644 --- a/src/test/ui/nll/get_default.stderr +++ b/src/test/ui/nll/get_default.stderr @@ -34,7 +34,7 @@ error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as imm 51 | } | - immutable borrow ends here -error[E0502]: cannot borrow `(*map)` as mutable because it is also borrowed as immutable (Mir) +error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) --> $DIR/get_default.rs:43:17 | 41 | match map.get() { |
