Skip to content

Commit

Permalink
Address review feedback: don't treat "first" activation special.
Browse files Browse the repository at this point in the history
Instead, filter out (non-)conflicts of activiations with themselves in
the same manner that we filter out non-conflict between an activation
and its reservation.
  • Loading branch information
pnkfelix committed Dec 14, 2017
1 parent d654cd3 commit 159037e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/librustc_mir/borrow_check/mod.rs
Expand Up @@ -732,10 +732,19 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
(sd, place_span.0),
flow_state,
|this, index, borrow| match (rw, borrow.kind) {
// Obviously an activation is compatible with its own reservation;
// so don't check if they interfere.
(Activation(_, activating), _) if index.is_reservation() &&
activating == index.borrow_index() => Control::Continue,
// Obviously an activation is compatible with its own
// reservation (or even prior activating uses of same
// borrow); so don't check if they interfere.
//
// NOTE: *reservations* do conflict with themselves;
// thus aren't injecting unsoundenss w/ this check.)
(Activation(_, activating), _) if activating == index.borrow_index() =>
{
debug!("check_access_for_conflict place_span: {:?} sd: {:?} rw: {:?} \
skipping {:?} b/c activation of same borrow_index: {:?}",
place_span, sd, rw, (index, borrow), index.borrow_index());
Control::Continue
}

(Read(_), BorrowKind::Shared) |
(Reservation(..), BorrowKind::Shared) => Control::Continue,
Expand Down Expand Up @@ -1086,8 +1095,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
let domain = flow_state.borrows.operator();
let data = domain.borrows();
flow_state.borrows.each_gen_bit(|gen| {
if gen.is_activation() && // must be activation,
!flow_state.borrows.contains(&gen) // and newly generated.
if gen.is_activation()
{
let borrow_index = gen.borrow_index();
let borrow = &data[borrow_index];
Expand Down

0 comments on commit 159037e

Please sign in to comment.