Swapped order of left/right visits to ensure consistency in read/write pass ordering when -O is passed.
This commit is contained in:
parent
970fb1a77f
commit
5cd4b4fd95
@ -347,6 +347,13 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx
|
||||
|
||||
match stmt.kind {
|
||||
StatementKind::Assign(ref lhs, ref rhs) => {
|
||||
self.consume_rvalue(
|
||||
ContextKind::AssignRhs.new(location),
|
||||
(rhs, span),
|
||||
location,
|
||||
flow_state,
|
||||
);
|
||||
|
||||
self.mutate_place(
|
||||
ContextKind::AssignLhs.new(location),
|
||||
(lhs, span),
|
||||
@ -354,13 +361,6 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx
|
||||
JustWrite,
|
||||
flow_state,
|
||||
);
|
||||
|
||||
self.consume_rvalue(
|
||||
ContextKind::AssignRhs.new(location),
|
||||
(rhs, span),
|
||||
location,
|
||||
flow_state,
|
||||
);
|
||||
}
|
||||
StatementKind::SetDiscriminant {
|
||||
ref place,
|
||||
|
@ -19,7 +19,7 @@ fn foo() {
|
||||
let mut x = 22;
|
||||
let wrapper = Wrap { w: &mut x };
|
||||
x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506]
|
||||
//[mir]~^ ERROR cannot assign to `x` because it is borrowed [E0506]
|
||||
//[mir]~^ ERROR cannot use `x` because it was mutably borrowed [E0503]
|
||||
*wrapper.w += 1;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ fn main() {
|
||||
let z = copy_borrowed_ptr(&mut y);
|
||||
*y.pointer += 1;
|
||||
//~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506]
|
||||
//~| ERROR cannot assign to `*y.pointer` because it is borrowed (Mir) [E0506]
|
||||
//~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503]
|
||||
*z.pointer += 1;
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,13 @@ error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast)
|
||||
30 | *y.pointer += 1;
|
||||
| ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
|
||||
|
||||
error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir)
|
||||
error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir)
|
||||
--> $DIR/issue-45697.rs:30:9
|
||||
|
|
||||
29 | let z = copy_borrowed_ptr(&mut y);
|
||||
| ------ borrow of `*y.pointer` occurs here
|
||||
| ------ borrow of `y` occurs here
|
||||
30 | *y.pointer += 1;
|
||||
| ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
|
||||
| ^^^^^^^^^^^^^^^ use of borrowed `y`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user