Skip to content

Commit 5cd4b4f

Browse files
committed
Swapped order of left/right visits to ensure consistency in read/write pass ordering when -O is passed.
1 parent 970fb1a commit 5cd4b4f

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/librustc_mir/borrow_check/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -347,20 +347,20 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx
347347

348348
match stmt.kind {
349349
StatementKind::Assign(ref lhs, ref rhs) => {
350+
self.consume_rvalue(
351+
ContextKind::AssignRhs.new(location),
352+
(rhs, span),
353+
location,
354+
flow_state,
355+
);
356+
350357
self.mutate_place(
351358
ContextKind::AssignLhs.new(location),
352359
(lhs, span),
353360
Shallow(None),
354361
JustWrite,
355362
flow_state,
356363
);
357-
358-
self.consume_rvalue(
359-
ContextKind::AssignRhs.new(location),
360-
(rhs, span),
361-
location,
362-
flow_state,
363-
);
364364
}
365365
StatementKind::SetDiscriminant {
366366
ref place,

src/test/compile-fail/nll/reference-carried-through-struct-field.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn foo() {
1919
let mut x = 22;
2020
let wrapper = Wrap { w: &mut x };
2121
x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506]
22-
//[mir]~^ ERROR cannot assign to `x` because it is borrowed [E0506]
22+
//[mir]~^ ERROR cannot use `x` because it was mutably borrowed [E0503]
2323
*wrapper.w += 1;
2424
}
2525

src/test/ui/issue-45697.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() {
2929
let z = copy_borrowed_ptr(&mut y);
3030
*y.pointer += 1;
3131
//~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506]
32-
//~| ERROR cannot assign to `*y.pointer` because it is borrowed (Mir) [E0506]
32+
//~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503]
3333
*z.pointer += 1;
3434
}
3535
}

src/test/ui/issue-45697.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast)
66
30 | *y.pointer += 1;
77
| ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
88

9-
error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir)
9+
error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir)
1010
--> $DIR/issue-45697.rs:30:9
1111
|
1212
29 | let z = copy_borrowed_ptr(&mut y);
13-
| ------ borrow of `*y.pointer` occurs here
13+
| ------ borrow of `y` occurs here
1414
30 | *y.pointer += 1;
15-
| ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
15+
| ^^^^^^^^^^^^^^^ use of borrowed `y`
1616

1717
error: aborting due to 2 previous errors
1818

0 commit comments

Comments
 (0)