@@ -135,13 +135,11 @@ fn place_components_conflict<'tcx>(
135135 }
136136
137137 // loop invariant: borrow_c is always either equal to access_c or disjoint from it.
138- for ( i , ( borrow_c, & access_c) ) in
139- iter:: zip ( borrow_place. projection , access_place. projection ) . enumerate ( )
138+ for ( ( borrow_place , borrow_c) , & access_c) in
139+ iter:: zip ( borrow_place. iter_projections ( ) , access_place. projection )
140140 {
141141 debug ! ( ?borrow_c, ?access_c) ;
142142
143- let borrow_proj_base = & borrow_place. projection [ ..i] ;
144-
145143 // Borrow and access path both have more components.
146144 //
147145 // Examples:
@@ -154,15 +152,7 @@ fn place_components_conflict<'tcx>(
154152 // check whether the components being borrowed vs
155153 // accessed are disjoint (as in the second example,
156154 // but not the first).
157- match place_projection_conflict (
158- tcx,
159- body,
160- borrow_local,
161- borrow_proj_base,
162- borrow_c,
163- access_c,
164- bias,
165- ) {
155+ match place_projection_conflict ( tcx, body, borrow_place, borrow_c, access_c, bias) {
166156 Overlap :: Arbitrary => {
167157 // We have encountered different fields of potentially
168158 // the same union - the borrow now partially overlaps.
@@ -193,8 +183,7 @@ fn place_components_conflict<'tcx>(
193183 }
194184
195185 if borrow_place. projection . len ( ) > access_place. projection . len ( ) {
196- for ( i, elem) in borrow_place. projection [ access_place. projection . len ( ) ..] . iter ( ) . enumerate ( )
197- {
186+ for ( base, elem) in borrow_place. iter_projections ( ) . skip ( access_place. projection . len ( ) ) {
198187 // Borrow path is longer than the access path. Examples:
199188 //
200189 // - borrow of `a.b.c`, access to `a.b`
@@ -203,8 +192,7 @@ fn place_components_conflict<'tcx>(
203192 // our place. This is a conflict if that is a part our
204193 // access cares about.
205194
206- let proj_base = & borrow_place. projection [ ..access_place. projection . len ( ) + i] ;
207- let base_ty = Place :: ty_from ( borrow_local, proj_base, body, tcx) . ty ;
195+ let base_ty = base. ty ( body, tcx) . ty ;
208196
209197 match ( elem, & base_ty. kind ( ) , access) {
210198 ( _, _, Shallow ( Some ( ArtificialField :: ArrayLength ) ) )
@@ -308,8 +296,7 @@ fn place_base_conflict(l1: Local, l2: Local) -> Overlap {
308296fn place_projection_conflict < ' tcx > (
309297 tcx : TyCtxt < ' tcx > ,
310298 body : & Body < ' tcx > ,
311- pi1_local : Local ,
312- pi1_proj_base : & [ PlaceElem < ' tcx > ] ,
299+ pi1 : PlaceRef < ' tcx > ,
313300 pi1_elem : PlaceElem < ' tcx > ,
314301 pi2_elem : PlaceElem < ' tcx > ,
315302 bias : PlaceConflictBias ,
@@ -331,7 +318,7 @@ fn place_projection_conflict<'tcx>(
331318 debug ! ( "place_element_conflict: DISJOINT-OR-EQ-FIELD" ) ;
332319 Overlap :: EqualOrDisjoint
333320 } else {
334- let ty = Place :: ty_from ( pi1_local , pi1_proj_base , body, tcx) . ty ;
321+ let ty = pi1 . ty ( body, tcx) . ty ;
335322 if ty. is_union ( ) {
336323 // Different fields of a union, we are basically stuck.
337324 debug ! ( "place_element_conflict: STUCK-UNION" ) ;
0 commit comments