10
10
11
11
use borrow_check:: ArtificialField ;
12
12
use borrow_check:: Overlap ;
13
- use borrow_check:: { ShallowOrDeep , Deep , Shallow } ;
13
+ use borrow_check:: { Deep , Shallow , ShallowOrDeep } ;
14
14
use rustc:: hir;
15
15
use rustc:: mir:: { Mir , Place } ;
16
16
use rustc:: mir:: { Projection , ProjectionElem } ;
@@ -148,19 +148,19 @@ fn place_components_conflict<'gcx, 'tcx>(
148
148
149
149
match ( elem, & base_ty. sty , access) {
150
150
( _, _, Shallow ( Some ( ArtificialField :: Discriminant ) ) )
151
- | ( _, _, Shallow ( Some ( ArtificialField :: ArrayLength ) ) ) => {
152
- // The discriminant and array length are like
153
- // additional fields on the type; they do not
154
- // overlap any existing data there. Furthermore,
155
- // they cannot actually be a prefix of any
156
- // borrowed place (at least in MIR as it is
157
- // currently.)
158
- //
159
- // e.g. a (mutable) borrow of `a[5]` while we read the
160
- // array length of `a`.
161
- debug ! ( "places_conflict: implicit field" ) ;
162
- return false ;
163
- }
151
+ | ( _, _, Shallow ( Some ( ArtificialField :: ArrayLength ) ) ) => {
152
+ // The discriminant and array length are like
153
+ // additional fields on the type; they do not
154
+ // overlap any existing data there. Furthermore,
155
+ // they cannot actually be a prefix of any
156
+ // borrowed place (at least in MIR as it is
157
+ // currently.)
158
+ //
159
+ // e.g. a (mutable) borrow of `a[5]` while we read the
160
+ // array length of `a`.
161
+ debug ! ( "places_conflict: implicit field" ) ;
162
+ return false ;
163
+ }
164
164
165
165
( ProjectionElem :: Deref , _, Shallow ( None ) ) => {
166
166
// e.g. a borrow of `*x.y` while we shallowly access `x.y` or some
@@ -169,11 +169,7 @@ fn place_components_conflict<'gcx, 'tcx>(
169
169
debug ! ( "places_conflict: shallow access behind ptr" ) ;
170
170
return false ;
171
171
}
172
- (
173
- ProjectionElem :: Deref ,
174
- ty:: TyRef ( _, _, hir:: MutImmutable ) ,
175
- _,
176
- ) => {
172
+ ( ProjectionElem :: Deref , ty:: TyRef ( _, _, hir:: MutImmutable ) , _) => {
177
173
// the borrow goes through a dereference of a shared reference.
178
174
//
179
175
// I'm not sure why we are tracking these borrows - shared
@@ -184,16 +180,16 @@ fn place_components_conflict<'gcx, 'tcx>(
184
180
}
185
181
186
182
( ProjectionElem :: Deref , _, Deep )
187
- | ( ProjectionElem :: Field { .. } , _, _)
188
- | ( ProjectionElem :: Index { .. } , _, _)
189
- | ( ProjectionElem :: ConstantIndex { .. } , _, _)
190
- | ( ProjectionElem :: Subslice { .. } , _, _)
191
- | ( ProjectionElem :: Downcast { .. } , _, _) => {
192
- // Recursive case. This can still be disjoint on a
193
- // further iteration if this a shallow access and
194
- // there's a deref later on, e.g. a borrow
195
- // of `*x.y` while accessing `x`.
196
- }
183
+ | ( ProjectionElem :: Field { .. } , _, _)
184
+ | ( ProjectionElem :: Index { .. } , _, _)
185
+ | ( ProjectionElem :: ConstantIndex { .. } , _, _)
186
+ | ( ProjectionElem :: Subslice { .. } , _, _)
187
+ | ( ProjectionElem :: Downcast { .. } , _, _) => {
188
+ // Recursive case. This can still be disjoint on a
189
+ // further iteration if this a shallow access and
190
+ // there's a deref later on, e.g. a borrow
191
+ // of `*x.y` while accessing `x`.
192
+ }
197
193
}
198
194
}
199
195
} else {
@@ -250,7 +246,7 @@ impl<'p, 'tcx> PlaceComponents<'p, 'tcx> {
250
246
/// manually invokes `next`. This is because we (sometimes) want to
251
247
/// keep executing even after `None` has been returned.
252
248
struct PlaceComponentsIter < ' p , ' tcx : ' p > {
253
- value : Option < & ' p PlaceComponents < ' p , ' tcx > >
249
+ value : Option < & ' p PlaceComponents < ' p , ' tcx > > ,
254
250
}
255
251
256
252
impl < ' p , ' tcx > PlaceComponentsIter < ' p , ' tcx > {
@@ -269,19 +265,17 @@ impl<'p, 'tcx> PlaceComponentsIter<'p, 'tcx> {
269
265
fn unroll_place < ' tcx , R > (
270
266
place : & Place < ' tcx > ,
271
267
next : Option < & PlaceComponents < ' _ , ' tcx > > ,
272
- op : impl FnOnce ( PlaceComponentsIter < ' _ , ' tcx > ) -> R
268
+ op : impl FnOnce ( PlaceComponentsIter < ' _ , ' tcx > ) -> R ,
273
269
) -> R {
274
270
match place {
275
- Place :: Projection ( interior) => {
276
- unroll_place (
277
- & interior. base ,
278
- Some ( & PlaceComponents {
279
- component : place,
280
- next,
281
- } ) ,
282
- op,
283
- )
284
- }
271
+ Place :: Projection ( interior) => unroll_place (
272
+ & interior. base ,
273
+ Some ( & PlaceComponents {
274
+ component : place,
275
+ next,
276
+ } ) ,
277
+ op,
278
+ ) ,
285
279
286
280
Place :: Local ( _) | Place :: Static ( _) => {
287
281
let list = PlaceComponents {
@@ -300,7 +294,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>(
300
294
tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
301
295
mir : & Mir < ' tcx > ,
302
296
elem1 : & Place < ' tcx > ,
303
- elem2 : & Place < ' tcx >
297
+ elem2 : & Place < ' tcx > ,
304
298
) -> Overlap {
305
299
match ( elem1, elem2) {
306
300
( Place :: Local ( l1) , Place :: Local ( l2) ) => {
@@ -318,8 +312,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>(
318
312
if static1. def_id != static2. def_id {
319
313
debug ! ( "place_element_conflict: DISJOINT-STATIC" ) ;
320
314
Overlap :: Disjoint
321
- } else if tcx. is_static ( static1. def_id ) ==
322
- Some ( hir:: Mutability :: MutMutable ) {
315
+ } else if tcx. is_static ( static1. def_id ) == Some ( hir:: Mutability :: MutMutable ) {
323
316
// We ignore mutable statics - they can only be unsafe code.
324
317
debug ! ( "place_element_conflict: IGNORE-STATIC-MUT" ) ;
325
318
Overlap :: Disjoint
@@ -397,10 +390,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>(
397
390
| ( ProjectionElem :: Index ( ..) , ProjectionElem :: ConstantIndex { .. } )
398
391
| ( ProjectionElem :: Index ( ..) , ProjectionElem :: Subslice { .. } )
399
392
| ( ProjectionElem :: ConstantIndex { .. } , ProjectionElem :: Index ( ..) )
400
- | (
401
- ProjectionElem :: ConstantIndex { .. } ,
402
- ProjectionElem :: ConstantIndex { .. } ,
403
- )
393
+ | ( ProjectionElem :: ConstantIndex { .. } , ProjectionElem :: ConstantIndex { .. } )
404
394
| ( ProjectionElem :: ConstantIndex { .. } , ProjectionElem :: Subslice { .. } )
405
395
| ( ProjectionElem :: Subslice { .. } , ProjectionElem :: Index ( ..) )
406
396
| ( ProjectionElem :: Subslice { .. } , ProjectionElem :: ConstantIndex { .. } )
0 commit comments