Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
93c4ffe
Revised graphviz rendering API to avoid requiring borrowed state.
pnkfelix Nov 24, 2017
171c2ae
Expanded HIR `--unpretty hir,identified` to include HIR local id.
pnkfelix Nov 24, 2017
d4add5d
Refactoring: pull bitvector initialization out from other parts of da…
pnkfelix Nov 27, 2017
e123117
Refactoring: Allow `BlockSets.on_entry` to denote locally accumulated…
pnkfelix Nov 27, 2017
39e126c
Refactoring alpha-rename `place` (`BorrowData` field) to `borrowed_p…
pnkfelix Nov 28, 2017
e437e49
Implement Borrow/BorrowMut/ToOwned relationships betweed IdxSetBuf an…
pnkfelix Dec 1, 2017
ef64ace
Allow `mir::Place` to be used as a key in hashtables.
pnkfelix Dec 1, 2017
ced5a70
New `ActiveBorrows` dataflow for two-phase `&mut`; not yet borrowed-c…
pnkfelix Dec 1, 2017
658ed79
Add some doc to `each_borrow_involving_path` iteration function.
pnkfelix Dec 13, 2017
1334638
Add some doc to `struct Borrows`.
pnkfelix Dec 13, 2017
3621645
Incorporate active-borrows dataflow into MIR borrow check, yielding
pnkfelix Dec 1, 2017
5f759a9
the minimal test for two-phase borrows: the core example from niko's …
pnkfelix Dec 5, 2017
dbbec4d
tests transcribed from nikos blog post.
pnkfelix Dec 5, 2017
db5420b
test describing a currently unsupported corner case.
pnkfelix Dec 6, 2017
9cb92ac
two-phase-reservation-sharing-interference.rs variant that is perhaps…
pnkfelix Dec 6, 2017
18aedf6
Sidestep ICE from `MirBorrowckCtxt::find_closure_span`.
pnkfelix Dec 13, 2017
5cae7a0
Check activation points as the place where mutable borrows become rel…
pnkfelix Dec 7, 2017
3c7d9ff
Address review comment: use `.get` instead of indexing to cope w/ ter…
pnkfelix Dec 14, 2017
f96777c
After discussion with ariel, replacing a guard within kill_loans_out_…
pnkfelix Dec 14, 2017
b75248e
Address review note: `AccessErrorsReported` meant to track whether er…
pnkfelix Dec 14, 2017
b0421fa
Address review feedback: don't bother skipping reservations paired wi…
pnkfelix Dec 14, 2017
d654cd3
Review feedback: Added test with control flow merge of two borrows "b…
pnkfelix Dec 14, 2017
159037e
Address review feedback: don't treat "first" activation special.
pnkfelix Dec 14, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
After discussion with ariel, replacing a guard within kill_loans_out_…
…of_scope_at_location.

Instead we are "just" careful to invoke it (which sets up a bunch of kill bits)
before we go into the code that sets up the gen bits.

That way, when the gen bits are set up, they will override any
previously set kill-bits for those reservations or activations.
  • Loading branch information
pnkfelix committed Dec 14, 2017
commit f96777c9ffa1d564f26fee7ed64e4ccc4f8dd1fa
66 changes: 33 additions & 33 deletions src/librustc_mir/dataflow/impls/borrows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,32 +292,21 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
location: Location,
is_activations: bool) {
if let Some(ref regioncx) = self.nonlexical_regioncx {
// NOTE: The state associated with a given `location`
// reflects the dataflow on entry to the statement. If it
// does not contain `borrow_region`, then then that means
// that the statement at `location` kills the borrow.
//
// We are careful always to call this function *before* we
// set up the gen-bits for the statement or
// termanator. That way, if the effect of the statement or
// terminator *does* introduce a new loan of the same
// region, then setting that gen-bit will override any
// potential kill introduced here.
for (borrow_index, borrow_data) in self.borrows.iter_enumerated() {
let borrow_region = borrow_data.region.to_region_vid();
if !regioncx.region_contains_point(borrow_region, location) {
// The region checker really considers the borrow
// to start at the point **after** the location of
// the borrow, but the borrow checker puts the gen
// directly **on** the location of the
// borrow. This results in a gen/kill both being
// generated for same point if we are not
// careful. Probably we should change the point of
// the gen, but for now we hackily account for the
// mismatch here by not generating a kill for the
// location on the borrow itself.
if location != borrow_data.location {
sets.kill(&ReserveOrActivateIndex::reserved(borrow_index));
}

// FIXME: the logic used to justify the above
// "accounting for mismatch" does not generalize
// to activations, so we set the kill-bits without
// that same location check here.
//
// But... can we get into a situation where the
// gen/kill bits are both sets in this case, in
// which case we *do* need an analogous guard of
// some kind?
sets.kill(&ReserveOrActivateIndex::reserved(borrow_index));
if is_activations {
sets.kill(&ReserveOrActivateIndex::active(borrow_index));
}
Expand All @@ -340,14 +329,18 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
panic!("could not find statement at location {:?}");
});

// Do kills introduced by NLL before setting up any potential
// gens. (See NOTE in kill_loans_out_of_scope_at_location.)
self.kill_loans_out_of_scope_at_location(sets, location, is_activations);

if is_activations {
// INVARIANT: At this point, `sets.on_entry` should
// correctly reflect the reservations as we enter the
// statement (because accumulates_intrablock_state is
// overridden)
// INVARIANT: `sets.on_entry` accurately captures
// reservations on entry to statement (b/c
// accumulates_intrablock_state is overridden for
// ActiveBorrows).
//
// Now compute effect of the statement on the activations
// themselves in the ActiveBorrows state.
// Now compute the activations generated by uses within
// the statement based on that reservation state.
let mut find = FindPlaceUses { sets, assigned_map: &self.assigned_map };
find.visit_statement(location.block, stmt, location);
}
Expand Down Expand Up @@ -414,8 +407,6 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
mir::StatementKind::Nop => {}

}

self.kill_loans_out_of_scope_at_location(sets, location, is_activations);
}

/// Models terminator effect in Reservations and ActiveBorrows
Expand All @@ -429,9 +420,19 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
panic!("could not find block at location {:?}", location);
});

// Do kills introduced by NLL before setting up any potential
// gens. (See NOTE in kill_loans_out_of_scope_at_location.)
self.kill_loans_out_of_scope_at_location(sets, location, is_activations);

let term = block.terminator();
if is_activations {
// Any uses of reserved Places in the statement are now activated.
// INVARIANT: `sets.on_entry` accurately captures
// reservations on entry to terminator (b/c
// accumulates_intrablock_state is overridden for
// ActiveBorrows).
//
// Now compute effect of the terminator on the activations
// themselves in the ActiveBorrows state.
let mut find = FindPlaceUses { sets, assigned_map: &self.assigned_map };
find.visit_terminator(location.block, term, location);
}
Expand Down Expand Up @@ -474,7 +475,6 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
mir::TerminatorKind::FalseEdges {..} |
mir::TerminatorKind::Unreachable => {}
}
self.kill_loans_out_of_scope_at_location(sets, location, is_activations);
}
}

Expand Down