@@ -137,13 +137,11 @@ fn place_components_conflict<'tcx>(
137137 }
138138
139139 // loop invariant: borrow_c is always either equal to access_c or disjoint from it.
140- for ( i , ( borrow_c, & access_c) ) in
141- iter:: zip ( borrow_place. projection , access_place. projection ) . enumerate ( )
140+ for ( ( borrow_place , borrow_c) , & access_c) in
141+ iter:: zip ( borrow_place. iter_projections ( ) , access_place. projection )
142142 {
143143 debug ! ( ?borrow_c, ?access_c) ;
144144
145- let borrow_proj_base = & borrow_place. projection [ ..i] ;
146-
147145 // Borrow and access path both have more components.
148146 //
149147 // Examples:
@@ -156,15 +154,7 @@ fn place_components_conflict<'tcx>(
156154 // check whether the components being borrowed vs
157155 // accessed are disjoint (as in the second example,
158156 // but not the first).
159- match place_projection_conflict (
160- tcx,
161- body,
162- borrow_local,
163- borrow_proj_base,
164- borrow_c,
165- access_c,
166- bias,
167- ) {
157+ match place_projection_conflict ( tcx, body, borrow_place, borrow_c, access_c, bias) {
168158 Overlap :: Arbitrary => {
169159 // We have encountered different fields of potentially
170160 // the same union - the borrow now partially overlaps.
@@ -195,8 +185,7 @@ fn place_components_conflict<'tcx>(
195185 }
196186
197187 if borrow_place. projection . len ( ) > access_place. projection . len ( ) {
198- for ( i, elem) in borrow_place. projection [ access_place. projection . len ( ) ..] . iter ( ) . enumerate ( )
199- {
188+ for ( base, elem) in borrow_place. iter_projections ( ) . skip ( access_place. projection . len ( ) ) {
200189 // Borrow path is longer than the access path. Examples:
201190 //
202191 // - borrow of `a.b.c`, access to `a.b`
@@ -205,8 +194,7 @@ fn place_components_conflict<'tcx>(
205194 // our place. This is a conflict if that is a part our
206195 // access cares about.
207196
208- let proj_base = & borrow_place. projection [ ..access_place. projection . len ( ) + i] ;
209- let base_ty = Place :: ty_from ( borrow_local, proj_base, body, tcx) . ty ;
197+ let base_ty = base. ty ( body, tcx) . ty ;
210198
211199 match ( elem, & base_ty. kind ( ) , access) {
212200 ( _, _, Shallow ( Some ( ArtificialField :: ArrayLength ) ) )
@@ -310,8 +298,7 @@ fn place_base_conflict(l1: Local, l2: Local) -> Overlap {
310298fn place_projection_conflict < ' tcx > (
311299 tcx : TyCtxt < ' tcx > ,
312300 body : & Body < ' tcx > ,
313- pi1_local : Local ,
314- pi1_proj_base : & [ PlaceElem < ' tcx > ] ,
301+ pi1 : PlaceRef < ' tcx > ,
315302 pi1_elem : PlaceElem < ' tcx > ,
316303 pi2_elem : PlaceElem < ' tcx > ,
317304 bias : PlaceConflictBias ,
@@ -333,7 +320,7 @@ fn place_projection_conflict<'tcx>(
333320 debug ! ( "place_element_conflict: DISJOINT-OR-EQ-FIELD" ) ;
334321 Overlap :: EqualOrDisjoint
335322 } else {
336- let ty = Place :: ty_from ( pi1_local , pi1_proj_base , body, tcx) . ty ;
323+ let ty = pi1 . ty ( body, tcx) . ty ;
337324 if ty. is_union ( ) {
338325 // Different fields of a union, we are basically stuck.
339326 debug ! ( "place_element_conflict: STUCK-UNION" ) ;
0 commit comments