mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
mir-borrowck: Remove parens in the lvalue description of a deref
This commit is contained in:
parent
d8d5b6180f
commit
094d67ee37
@ -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(..) => {
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
@ -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() {}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user