Skip to content

Commit 159037e

Browse files
committed
Address review feedback: don't treat "first" activation special.
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.
1 parent d654cd3 commit 159037e

File tree

1 file changed

+14
-6
lines changed
  • src/librustc_mir/borrow_check

1 file changed

+14
-6
lines changed

src/librustc_mir/borrow_check/mod.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,19 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
732732
(sd, place_span.0),
733733
flow_state,
734734
|this, index, borrow| match (rw, borrow.kind) {
735-
// Obviously an activation is compatible with its own reservation;
736-
// so don't check if they interfere.
737-
(Activation(_, activating), _) if index.is_reservation() &&
738-
activating == index.borrow_index() => Control::Continue,
735+
// Obviously an activation is compatible with its own
736+
// reservation (or even prior activating uses of same
737+
// borrow); so don't check if they interfere.
738+
//
739+
// NOTE: *reservations* do conflict with themselves;
740+
// thus aren't injecting unsoundenss w/ this check.)
741+
(Activation(_, activating), _) if activating == index.borrow_index() =>
742+
{
743+
debug!("check_access_for_conflict place_span: {:?} sd: {:?} rw: {:?} \
744+
skipping {:?} b/c activation of same borrow_index: {:?}",
745+
place_span, sd, rw, (index, borrow), index.borrow_index());
746+
Control::Continue
747+
}
739748

740749
(Read(_), BorrowKind::Shared) |
741750
(Reservation(..), BorrowKind::Shared) => Control::Continue,
@@ -1086,8 +1095,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
10861095
let domain = flow_state.borrows.operator();
10871096
let data = domain.borrows();
10881097
flow_state.borrows.each_gen_bit(|gen| {
1089-
if gen.is_activation() && // must be activation,
1090-
!flow_state.borrows.contains(&gen) // and newly generated.
1098+
if gen.is_activation()
10911099
{
10921100
let borrow_index = gen.borrow_index();
10931101
let borrow = &data[borrow_index];

0 commit comments

Comments
 (0)