Skip to content

Commit

Permalink
Swapped order of left/right visits to ensure consistency in read/writ…
Browse files Browse the repository at this point in the history
…e pass ordering when -O is passed.
  • Loading branch information
davidtwco committed Feb 5, 2018
1 parent 970fb1a commit 5cd4b4f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,20 +347,20 @@ 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),
Shallow(None),
JustWrite,
flow_state,
);

self.consume_rvalue(
ContextKind::AssignRhs.new(location),
(rhs, span),
location,
flow_state,
);
}
StatementKind::SetDiscriminant {
ref place,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issue-45697.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 3 additions & 3 deletions src/test/ui/issue-45697.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5cd4b4f

Please sign in to comment.