Skip to content

Commit 03f198f

Browse files
Fix tests after two-phase borrow rewrite
1 parent e4e377f commit 03f198f

File tree

5 files changed

+14
-33
lines changed

5 files changed

+14
-33
lines changed

src/librustc_mir/dataflow/graphviz.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl<'a, 'tcx, MWF, P> dot::Labeller<'a> for Graph<'a, 'tcx, MWF, P>
111111
// | | | | bb11[0]: active |
112112
// +---------+----------------------------------+------------------+------------------+
113113
// | [00-00] | _7 = const Foo::twiddle(move _8) | [0c-00] | [f3-0f] |
114-
// +---------+----------------------------------+------------------+------------------+
114+
// +---------+----------------------------------+------------------+------------------+
115115
let mut v = Vec::new();
116116
self.node_label_internal(n, &mut v, *n, self.mbcx.mir()).unwrap();
117117
dot::LabelText::html(String::from_utf8(v).unwrap())
@@ -140,7 +140,7 @@ where MWF: MirWithFlowState<'tcx>,
140140
block: BasicBlock,
141141
mir: &Mir) -> io::Result<()> {
142142
// Header rows
143-
const HDRS: [&'static str; 4] = ["ENTRY", "MIR", "GEN", "KILL"];
143+
const HDRS: [&'static str; 4] = ["ENTRY", "MIR", "BLOCK GENS", "BLOCK KILLS"];
144144
const HDR_FMT: &'static str = "bgcolor=\"grey\"";
145145
write!(w, "<table><tr><td rowspan=\"{}\">", HDRS.len())?;
146146
write!(w, "{:?}", block.index())?;

src/librustc_mir/dataflow/impls/borrows.rs

+10-17
Original file line numberDiff line numberDiff line change
@@ -272,17 +272,6 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
272272
}
273273
}
274274

275-
/// Represents what kind of usage we've seen.
276-
enum PlaceUsageType {
277-
/// No usage seen
278-
None,
279-
/// Has been seen as the argument to a StorageDead statement. This is required to
280-
/// gracefully handle cases where user code has an unneeded
281-
StorageKilled,
282-
/// Has been used in borrow-activating context
283-
BorrowActivateUsage
284-
}
285-
286275
/// A MIR visitor that determines if a specific place is used in a two-phase activating
287276
/// manner in a given chunk of MIR.
288277
struct ContainsUseOfPlace<'b, 'tcx: 'b> {
@@ -404,7 +393,8 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
404393
let stmt = &block_data.statements[location.statement_index];
405394
if let mir::StatementKind::EndRegion(region_scope) = stmt.kind {
406395
if &ReScope(region_scope) == region {
407-
// We encountered an EndRegion statement that terminates the provided region
396+
// We encountered an EndRegion statement that terminates the provided
397+
// region
408398
return true;
409399
}
410400
}
@@ -430,7 +420,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
430420
/// See
431421
/// - https://github.com/rust-lang/rust/issues/48431
432422
/// for detailed design notes.
433-
/// See the TODO in the body of the function for notes on extending support to more
423+
/// See the FIXME in the body of the function for notes on extending support to more
434424
/// general two-phased borrows.
435425
fn compute_activation_location(&self,
436426
start_location: Location,
@@ -473,7 +463,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
473463
}
474464

475465
if self.location_contains_use(curr_loc, assigned_place) {
476-
// TODO: Handle this case a little more gracefully. Perhaps collect
466+
// FIXME: Handle this case a little more gracefully. Perhaps collect
477467
// all uses in a vector, and find the point in the CFG that dominates
478468
// all of them?
479469
// Right now this is sufficient though since there should only be exactly
@@ -596,7 +586,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for Borrows<'a, 'gcx, 'tcx> {
596586
// `_sets`.
597587
}
598588

599-
fn before_statement_effect(&self, sets: &mut BlockSets<ReserveOrActivateIndex>, location: Location) {
589+
fn before_statement_effect(&self,
590+
sets: &mut BlockSets<ReserveOrActivateIndex>,
591+
location: Location) {
600592
debug!("Borrows::before_statement_effect sets: {:?} location: {:?}", sets, location);
601593
self.kill_loans_out_of_scope_at_location(sets, location);
602594
}
@@ -662,7 +654,6 @@ impl<'a, 'gcx, 'tcx> BitDenotation for Borrows<'a, 'gcx, 'tcx> {
662654

663655
// Issue #46746: Two-phase borrows handles
664656
// stmts of form `Tmp = &mut Borrow` ...
665-
// XXX bob_twinkles experiment with removing this
666657
match lhs {
667658
Place::Local(..) | Place::Static(..) => {} // okay
668659
Place::Projection(..) => {
@@ -704,7 +695,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for Borrows<'a, 'gcx, 'tcx> {
704695
}
705696
}
706697

707-
fn before_terminator_effect(&self, sets: &mut BlockSets<ReserveOrActivateIndex>, location: Location) {
698+
fn before_terminator_effect(&self,
699+
sets: &mut BlockSets<ReserveOrActivateIndex>,
700+
location: Location) {
708701
debug!("Borrows::before_terminator_effect sets: {:?} location: {:?}", sets, location);
709702
self.kill_loans_out_of_scope_at_location(sets, location);
710703
}

src/test/compile-fail/nll/region-ends-after-if-condition.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// in the type of `p` includes the points after `&v[0]` up to (but not
1313
// including) the call to `use_x`. The `else` branch is not included.
1414

15-
// compile-flags:-Zborrowck=compare -Znll
15+
// compile-flags:-Zborrowck=compare -Znll -Ztwo-phase-borrows
1616

1717
#![allow(warnings)]
1818
#![feature(rustc_attrs)]

src/test/ui/issue-45157.rs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ fn main() {
3737
let nref = &u.z.c;
3838
//~^ ERROR cannot borrow `u.z.c` as immutable because it is also borrowed as mutable [E0502]
3939
println!("{} {}", mref, nref)
40-
//~^ ERROR cannot borrow `u.s.a` as mutable because it is also borrowed as immutable [E0502]
4140
}
4241
}
4342

src/test/ui/issue-45157.stderr

+1-12
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,6 @@ LL | //~^ ERROR cannot borrow `u.z.c` as immutable because it is also bo
1010
LL | println!("{} {}", mref, nref)
1111
| ---- borrow later used here
1212

13-
error[E0502]: cannot borrow `u.s.a` as mutable because it is also borrowed as immutable
14-
--> $DIR/issue-45157.rs:39:27
15-
|
16-
LL | let nref = &u.z.c;
17-
| ------ immutable borrow occurs here
18-
LL | //~^ ERROR cannot borrow `u.z.c` as immutable because it is also borrowed as mutable [E0502]
19-
LL | println!("{} {}", mref, nref)
20-
| ^^^^ ---- borrow later used here
21-
| |
22-
| mutable borrow occurs here
23-
24-
error: aborting due to 2 previous errors
13+
error: aborting due to previous error
2514

2615
If you want more information on this error, try using "rustc --explain E0502"

0 commit comments

Comments
 (0)