@@ -37,7 +37,7 @@ use dataflow::MoveDataParamEnv;
37
37
use dataflow:: { DataflowResultsConsumer } ;
38
38
use dataflow:: { MaybeInitializedPlaces , MaybeUninitializedPlaces } ;
39
39
use dataflow:: { EverInitializedPlaces , MovingOutStatements } ;
40
- use dataflow:: { Borrows , ReserveOrActivateIndex } ;
40
+ use dataflow:: Borrows ;
41
41
use dataflow:: indexes:: BorrowIndex ;
42
42
use dataflow:: move_paths:: { IllegalMoveOriginKind , MoveError } ;
43
43
use dataflow:: move_paths:: { HasMoveData , LookupResult , MoveData , MovePathIndex } ;
@@ -66,6 +66,8 @@ pub fn provide(providers: &mut Providers) {
66
66
} ;
67
67
}
68
68
69
+ struct IsActive ( bool ) ;
70
+
69
71
fn mir_borrowck < ' a , ' tcx > (
70
72
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
71
73
def_id : DefId ,
@@ -846,22 +848,21 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
846
848
context,
847
849
( sd, place_span. 0 ) ,
848
850
flow_state,
849
- |this, index , borrow| match ( rw, borrow. kind ) {
851
+ |this, borrow_index , is_active , borrow| match ( rw, borrow. kind ) {
850
852
// Obviously an activation is compatible with its own
851
853
// reservation (or even prior activating uses of same
852
854
// borrow); so don't check if they interfere.
853
855
//
854
856
// NOTE: *reservations* do conflict with themselves;
855
857
// thus aren't injecting unsoundenss w/ this check.)
856
- ( Activation ( _, activating) , _) if activating == index . borrow_index ( ) => {
858
+ ( Activation ( _, activating) , _) if activating == borrow_index => {
857
859
debug ! (
858
860
"check_access_for_conflict place_span: {:?} sd: {:?} rw: {:?} \
859
- skipping {:?} b/c activation of same borrow_index: {:?} ",
861
+ skipping {:?} b/c activation of same borrow_index",
860
862
place_span,
861
863
sd,
862
864
rw,
863
- ( index, borrow) ,
864
- index. borrow_index( )
865
+ ( borrow_index, borrow) ,
865
866
) ;
866
867
Control :: Continue
867
868
}
@@ -872,7 +873,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
872
873
873
874
( Read ( kind) , BorrowKind :: Unique ) | ( Read ( kind) , BorrowKind :: Mut { .. } ) => {
874
875
// Reading from mere reservations of mutable-borrows is OK.
875
- if this. allow_two_phase_borrow ( borrow. kind ) && index . is_reservation ( ) {
876
+ if this. allow_two_phase_borrow ( borrow. kind ) && !is_active . 0 {
876
877
return Control :: Continue ;
877
878
}
878
879
@@ -2216,18 +2217,16 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
2216
2217
/// "Current borrow" here means a borrow that reaches the point in
2217
2218
/// the control-flow where the access occurs.
2218
2219
///
2219
- /// The borrow's phase is represented by the ReserveOrActivateIndex
2220
- /// passed to the callback: one can call `is_reservation()` and
2221
- /// `is_activation()` to determine what phase the borrow is
2222
- /// currently in, when such distinction matters.
2220
+ /// The borrow's phase is represented by the IsActive parameter
2221
+ /// passed to the callback.
2223
2222
fn each_borrow_involving_path < F > (
2224
2223
& mut self ,
2225
2224
_context : Context ,
2226
2225
access_place : ( ShallowOrDeep , & Place < ' tcx > ) ,
2227
2226
flow_state : & Flows < ' cx , ' gcx , ' tcx > ,
2228
2227
mut op : F ,
2229
2228
) where
2230
- F : FnMut ( & mut Self , ReserveOrActivateIndex , & BorrowData < ' tcx > ) -> Control ,
2229
+ F : FnMut ( & mut Self , BorrowIndex , IsActive , & BorrowData < ' tcx > ) -> Control ,
2231
2230
{
2232
2231
let ( access, place) = access_place;
2233
2232
@@ -2247,7 +2246,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
2247
2246
"each_borrow_involving_path: {:?} @ {:?} vs. {:?}/{:?}" ,
2248
2247
i, borrowed, place, access
2249
2248
) ;
2250
- let ctrl = op ( self , i, borrowed) ;
2249
+ let is_active = IsActive ( i. is_activation ( ) ) ;
2250
+ let ctrl = op ( self , i. borrow_index ( ) , is_active, borrowed) ;
2251
2251
if ctrl == Control :: Break {
2252
2252
return ;
2253
2253
}
0 commit comments