Skip to content

Commit

Permalink
Rollup merge of rust-lang#52067 - csmoe:issue-51167, r=nikomatsakis
Browse files Browse the repository at this point in the history
Visit the mir basic blocks in reverse-postfix order

cc rust-lang#51167
r? @nikomatsakis
  • Loading branch information
Mark-Simulacrum committed Jul 7, 2018
2 parents b71b921 + e7e8c72 commit ec6bba3
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 45 deletions.
3 changes: 2 additions & 1 deletion src/librustc_mir/dataflow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use rustc_data_structures::work_queue::WorkQueue;

use rustc::ty::{self, TyCtxt};
use rustc::mir::{self, Mir, BasicBlock, BasicBlockData, Location, Statement, Terminator};
use rustc::mir::traversal;
use rustc::session::Session;

use std::borrow::Borrow;
Expand Down Expand Up @@ -332,7 +333,7 @@ pub(crate) trait DataflowResultsConsumer<'a, 'tcx: 'a> {

fn analyze_results(&mut self, flow_uninit: &mut Self::FlowState) {
let flow = flow_uninit;
for bb in self.mir().basic_blocks().indices() {
for (bb, _) in traversal::reverse_postorder(self.mir()) {
flow.reset_to_entry_of(bb);
self.process_basic_block(bb, flow);
}
Expand Down
7 changes: 3 additions & 4 deletions src/test/ui/issue-47184.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ error[E0597]: borrowed value does not live long enough
--> $DIR/issue-47184.rs:14:44
|
LL | let _vec: Vec<&'static String> = vec![&String::new()];
| ^^^^^^^^^^^^^ temporary value does not live long enough
LL | //~^ ERROR borrowed value does not live long enough [E0597]
LL | }
| - temporary value only lives until here
| ^^^^^^^^^^^^^ - temporary value only lives until here
| |
| temporary value does not live long enough
|
= note: borrowed value must be valid for the static lifetime...

Expand Down
24 changes: 12 additions & 12 deletions src/test/ui/nll/get_default.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ LL | | }
LL | | }
| |_^

error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
--> $DIR/get_default.rs:45:17
|
LL | match map.get() {
| --- immutable borrow occurs here
LL | Some(v) => {
LL | map.set(String::new()); // Both AST and MIR error here
| ^^^ mutable borrow occurs here
...
LL | return v;
| - borrow later used here

error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
--> $DIR/get_default.rs:51:17
|
Expand All @@ -76,18 +88,6 @@ LL | | }
LL | | }
| |_^

error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
--> $DIR/get_default.rs:45:17
|
LL | match map.get() {
| --- immutable borrow occurs here
LL | Some(v) => {
LL | map.set(String::new()); // Both AST and MIR error here
| ^^^ mutable borrow occurs here
...
LL | return v;
| - borrow later used here

error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0502`.
12 changes: 6 additions & 6 deletions src/test/ui/span/dropck_arr_cycle_checked.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error[E0597]: `b1` does not live long enough
--> $DIR/dropck_arr_cycle_checked.rs:111:24
error[E0597]: `b3` does not live long enough
--> $DIR/dropck_arr_cycle_checked.rs:105:24
|
LL | b3.a[0].v.set(Some(&b1));
LL | b1.a[1].v.set(Some(&b3));
| ^^^ borrowed value does not live long enough
...
LL | }
Expand All @@ -22,10 +22,10 @@ LL | }
| borrowed value only lives until here
| borrow later used here, when `b1` is dropped

error[E0597]: `b3` does not live long enough
--> $DIR/dropck_arr_cycle_checked.rs:105:24
error[E0597]: `b1` does not live long enough
--> $DIR/dropck_arr_cycle_checked.rs:111:24
|
LL | b1.a[1].v.set(Some(&b3));
LL | b3.a[0].v.set(Some(&b1));
| ^^^ borrowed value does not live long enough
...
LL | }
Expand Down
16 changes: 8 additions & 8 deletions src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
error[E0597]: `d1` does not live long enough
--> $DIR/dropck_direct_cycle_with_drop.rs:48:19
error[E0597]: `d2` does not live long enough
--> $DIR/dropck_direct_cycle_with_drop.rs:46:19
|
LL | d2.p.set(Some(&d1));
LL | d1.p.set(Some(&d2));
| ^^^ borrowed value does not live long enough
LL | //~^ ERROR `d1` does not live long enough
...
LL | }
| -
| |
Expand All @@ -12,12 +12,12 @@ LL | }
|
= note: values in a scope are dropped in the opposite order they are defined

error[E0597]: `d2` does not live long enough
--> $DIR/dropck_direct_cycle_with_drop.rs:46:19
error[E0597]: `d1` does not live long enough
--> $DIR/dropck_direct_cycle_with_drop.rs:48:19
|
LL | d1.p.set(Some(&d2));
LL | d2.p.set(Some(&d1));
| ^^^ borrowed value does not live long enough
...
LL | //~^ ERROR `d1` does not live long enough
LL | }
| -
| |
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/span/dropck_vec_cycle_checked.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error[E0597]: `c1` does not live long enough
--> $DIR/dropck_vec_cycle_checked.rs:121:24
error[E0597]: `c3` does not live long enough
--> $DIR/dropck_vec_cycle_checked.rs:115:24
|
LL | c3.v[0].v.set(Some(&c1));
LL | c1.v[1].v.set(Some(&c3));
| ^^^ borrowed value does not live long enough
...
LL | }
Expand All @@ -22,10 +22,10 @@ LL | }
| borrowed value only lives until here
| borrow later used here, when `c1` is dropped

error[E0597]: `c3` does not live long enough
--> $DIR/dropck_vec_cycle_checked.rs:115:24
error[E0597]: `c1` does not live long enough
--> $DIR/dropck_vec_cycle_checked.rs:121:24
|
LL | c1.v[1].v.set(Some(&c3));
LL | c3.v[0].v.set(Some(&c1));
| ^^^ borrowed value does not live long enough
...
LL | }
Expand Down
16 changes: 8 additions & 8 deletions src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
error[E0597]: `c1` does not live long enough
--> $DIR/vec-must-not-hide-type-from-dropck.rs:129:24
error[E0597]: `c2` does not live long enough
--> $DIR/vec-must-not-hide-type-from-dropck.rs:127:24
|
LL | c2.v[0].v.set(Some(&c1));
LL | c1.v[0].v.set(Some(&c2));
| ^^^ borrowed value does not live long enough
LL | //~^ ERROR `c1` does not live long enough
...
LL | }
| -
| |
| borrowed value only lives until here
| borrow later used here, when `c1` is dropped

error[E0597]: `c2` does not live long enough
--> $DIR/vec-must-not-hide-type-from-dropck.rs:127:24
error[E0597]: `c1` does not live long enough
--> $DIR/vec-must-not-hide-type-from-dropck.rs:129:24
|
LL | c1.v[0].v.set(Some(&c2));
LL | c2.v[0].v.set(Some(&c1));
| ^^^ borrowed value does not live long enough
...
LL | //~^ ERROR `c1` does not live long enough
LL | }
| -
| |
Expand Down

0 comments on commit ec6bba3

Please sign in to comment.