@@ -137,13 +137,11 @@ fn place_components_conflict<'tcx>(
137
137
}
138
138
139
139
// 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 )
142
142
{
143
143
debug ! ( ?borrow_c, ?access_c) ;
144
144
145
- let borrow_proj_base = & borrow_place. projection [ ..i] ;
146
-
147
145
// Borrow and access path both have more components.
148
146
//
149
147
// Examples:
@@ -156,15 +154,7 @@ fn place_components_conflict<'tcx>(
156
154
// check whether the components being borrowed vs
157
155
// accessed are disjoint (as in the second example,
158
156
// 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) {
168
158
Overlap :: Arbitrary => {
169
159
// We have encountered different fields of potentially
170
160
// the same union - the borrow now partially overlaps.
@@ -195,8 +185,7 @@ fn place_components_conflict<'tcx>(
195
185
}
196
186
197
187
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 ( ) ) {
200
189
// Borrow path is longer than the access path. Examples:
201
190
//
202
191
// - borrow of `a.b.c`, access to `a.b`
@@ -205,8 +194,7 @@ fn place_components_conflict<'tcx>(
205
194
// our place. This is a conflict if that is a part our
206
195
// access cares about.
207
196
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 ;
210
198
211
199
match ( elem, & base_ty. kind ( ) , access) {
212
200
( _, _, Shallow ( Some ( ArtificialField :: ArrayLength ) ) )
@@ -310,8 +298,7 @@ fn place_base_conflict(l1: Local, l2: Local) -> Overlap {
310
298
fn place_projection_conflict < ' tcx > (
311
299
tcx : TyCtxt < ' tcx > ,
312
300
body : & Body < ' tcx > ,
313
- pi1_local : Local ,
314
- pi1_proj_base : & [ PlaceElem < ' tcx > ] ,
301
+ pi1 : PlaceRef < ' tcx > ,
315
302
pi1_elem : PlaceElem < ' tcx > ,
316
303
pi2_elem : PlaceElem < ' tcx > ,
317
304
bias : PlaceConflictBias ,
@@ -333,7 +320,7 @@ fn place_projection_conflict<'tcx>(
333
320
debug ! ( "place_element_conflict: DISJOINT-OR-EQ-FIELD" ) ;
334
321
Overlap :: EqualOrDisjoint
335
322
} else {
336
- let ty = Place :: ty_from ( pi1_local , pi1_proj_base , body, tcx) . ty ;
323
+ let ty = pi1 . ty ( body, tcx) . ty ;
337
324
if ty. is_union ( ) {
338
325
// Different fields of a union, we are basically stuck.
339
326
debug ! ( "place_element_conflict: STUCK-UNION" ) ;
0 commit comments