Skip to content

Commit 87ec3b2

Browse files
committed
Activate two phase borrows on all uses
Two phase borrows are only used for adjustments now, so there's no need to not activate them for shared borrows.
1 parent 2c840ae commit 87ec3b2

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

src/librustc_mir/borrow_check/borrow_set.rs

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ use crate::borrow_check::nll::ToRegionVid;
33
use crate::dataflow::indexes::BorrowIndex;
44
use crate::dataflow::move_paths::MoveData;
55
use rustc::mir::traversal;
6-
use rustc::mir::visit::{
7-
PlaceContext, Visitor, NonUseContext, MutatingUseContext, NonMutatingUseContext
8-
};
6+
use rustc::mir::visit::{PlaceContext, Visitor, NonUseContext, MutatingUseContext};
97
use rustc::mir::{self, Location, Mir, Local};
108
use rustc::ty::{RegionVid, TyCtxt};
119
use rustc::util::nodemap::{FxHashMap, FxHashSet};
@@ -257,31 +255,21 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
257255
);
258256
}
259257

260-
// Otherwise, this is the unique later use
261-
// that we expect.
262-
borrow_data.activation_location = match context {
263-
// The use of TMP in a shared borrow does not
264-
// count as an actual activation.
265-
PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow(..)) |
266-
PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow(..)) =>
267-
TwoPhaseActivation::NotActivated,
268-
_ => {
269-
// Double check: This borrow is indeed a two-phase borrow (that is,
270-
// we are 'transitioning' from `NotActivated` to `ActivatedAt`) and
271-
// we've not found any other activations (checked above).
272-
assert_eq!(
273-
borrow_data.activation_location,
274-
TwoPhaseActivation::NotActivated,
275-
"never found an activation for this borrow!",
276-
);
277-
278-
self.activation_map
279-
.entry(location)
280-
.or_default()
281-
.push(borrow_index);
282-
TwoPhaseActivation::ActivatedAt(location)
283-
}
284-
};
258+
// Otherwise, this is the unique later use that we expect.
259+
// Double check: This borrow is indeed a two-phase borrow (that is,
260+
// we are 'transitioning' from `NotActivated` to `ActivatedAt`) and
261+
// we've not found any other activations (checked above).
262+
assert_eq!(
263+
borrow_data.activation_location,
264+
TwoPhaseActivation::NotActivated,
265+
"never found an activation for this borrow!",
266+
);
267+
self.activation_map
268+
.entry(location)
269+
.or_default()
270+
.push(borrow_index);
271+
272+
borrow_data.activation_location = TwoPhaseActivation::ActivatedAt(location);
285273
}
286274
}
287275

0 commit comments

Comments
 (0)