@@ -135,13 +135,11 @@ fn place_components_conflict<'tcx>(
135
135
}
136
136
137
137
// 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 )
140
140
{
141
141
debug ! ( ?borrow_c, ?access_c) ;
142
142
143
- let borrow_proj_base = & borrow_place. projection [ ..i] ;
144
-
145
143
// Borrow and access path both have more components.
146
144
//
147
145
// Examples:
@@ -154,15 +152,7 @@ fn place_components_conflict<'tcx>(
154
152
// check whether the components being borrowed vs
155
153
// accessed are disjoint (as in the second example,
156
154
// 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) {
166
156
Overlap :: Arbitrary => {
167
157
// We have encountered different fields of potentially
168
158
// the same union - the borrow now partially overlaps.
@@ -193,8 +183,7 @@ fn place_components_conflict<'tcx>(
193
183
}
194
184
195
185
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 ( ) ) {
198
187
// Borrow path is longer than the access path. Examples:
199
188
//
200
189
// - borrow of `a.b.c`, access to `a.b`
@@ -203,8 +192,7 @@ fn place_components_conflict<'tcx>(
203
192
// our place. This is a conflict if that is a part our
204
193
// access cares about.
205
194
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 ;
208
196
209
197
match ( elem, & base_ty. kind ( ) , access) {
210
198
( _, _, Shallow ( Some ( ArtificialField :: ArrayLength ) ) )
@@ -308,8 +296,7 @@ fn place_base_conflict(l1: Local, l2: Local) -> Overlap {
308
296
fn place_projection_conflict < ' tcx > (
309
297
tcx : TyCtxt < ' tcx > ,
310
298
body : & Body < ' tcx > ,
311
- pi1_local : Local ,
312
- pi1_proj_base : & [ PlaceElem < ' tcx > ] ,
299
+ pi1 : PlaceRef < ' tcx > ,
313
300
pi1_elem : PlaceElem < ' tcx > ,
314
301
pi2_elem : PlaceElem < ' tcx > ,
315
302
bias : PlaceConflictBias ,
@@ -331,7 +318,7 @@ fn place_projection_conflict<'tcx>(
331
318
debug ! ( "place_element_conflict: DISJOINT-OR-EQ-FIELD" ) ;
332
319
Overlap :: EqualOrDisjoint
333
320
} else {
334
- let ty = Place :: ty_from ( pi1_local , pi1_proj_base , body, tcx) . ty ;
321
+ let ty = pi1 . ty ( body, tcx) . ty ;
335
322
if ty. is_union ( ) {
336
323
// Different fields of a union, we are basically stuck.
337
324
debug ! ( "place_element_conflict: STUCK-UNION" ) ;
0 commit comments