about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2017-12-14 17:34:16 -0600
committerFelix S. Klock II <pnkfelix@pnkfx.org>2017-12-14 17:34:16 -0600
commit159037e05383f2349a709aa1c1681f11f89c552a (patch)
tree4dbd23ec3e112d27232282db1871d4544d23c52f
parentd654cd3b8bdbeee7a0bf9dac89de7e3e4f535e99 (diff)
downloadrust-159037e05383f2349a709aa1c1681f11f89c552a.tar.gz
rust-159037e05383f2349a709aa1c1681f11f89c552a.zip
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.
-rw-r--r--src/librustc_mir/borrow_check/mod.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs
index adb4a7a9255..39bcd2b6ae0 100644
--- a/src/librustc_mir/borrow_check/mod.rs
+++ b/src/librustc_mir/borrow_check/mod.rs
@@ -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,
@@ -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];