1010
1111use borrow_check:: ArtificialField ;
1212use borrow_check:: Overlap ;
13- use borrow_check:: { ShallowOrDeep , Deep , Shallow } ;
13+ use borrow_check:: { Deep , Shallow , ShallowOrDeep } ;
1414use rustc:: hir;
1515use rustc:: mir:: { Mir , Place } ;
1616use rustc:: mir:: { Projection , ProjectionElem } ;
@@ -148,19 +148,19 @@ fn place_components_conflict<'gcx, 'tcx>(
148148
149149 match ( elem, & base_ty. sty , access) {
150150 ( _, _, 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+ }
164164
165165 ( ProjectionElem :: Deref , _, Shallow ( None ) ) => {
166166 // 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>(
169169 debug ! ( "places_conflict: shallow access behind ptr" ) ;
170170 return false ;
171171 }
172- (
173- ProjectionElem :: Deref ,
174- ty:: TyRef ( _, _, hir:: MutImmutable ) ,
175- _,
176- ) => {
172+ ( ProjectionElem :: Deref , ty:: TyRef ( _, _, hir:: MutImmutable ) , _) => {
177173 // the borrow goes through a dereference of a shared reference.
178174 //
179175 // I'm not sure why we are tracking these borrows - shared
@@ -184,16 +180,16 @@ fn place_components_conflict<'gcx, 'tcx>(
184180 }
185181
186182 ( 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+ }
197193 }
198194 }
199195 } else {
@@ -250,7 +246,7 @@ impl<'p, 'tcx> PlaceComponents<'p, 'tcx> {
250246/// manually invokes `next`. This is because we (sometimes) want to
251247/// keep executing even after `None` has been returned.
252248struct PlaceComponentsIter < ' p , ' tcx : ' p > {
253- value : Option < & ' p PlaceComponents < ' p , ' tcx > >
249+ value : Option < & ' p PlaceComponents < ' p , ' tcx > > ,
254250}
255251
256252impl < ' p , ' tcx > PlaceComponentsIter < ' p , ' tcx > {
@@ -269,19 +265,17 @@ impl<'p, 'tcx> PlaceComponentsIter<'p, 'tcx> {
269265fn unroll_place < ' tcx , R > (
270266 place : & Place < ' tcx > ,
271267 next : Option < & PlaceComponents < ' _ , ' tcx > > ,
272- op : impl FnOnce ( PlaceComponentsIter < ' _ , ' tcx > ) -> R
268+ op : impl FnOnce ( PlaceComponentsIter < ' _ , ' tcx > ) -> R ,
273269) -> R {
274270 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+ ) ,
285279
286280 Place :: Local ( _) | Place :: Static ( _) => {
287281 let list = PlaceComponents {
@@ -300,7 +294,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>(
300294 tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
301295 mir : & Mir < ' tcx > ,
302296 elem1 : & Place < ' tcx > ,
303- elem2 : & Place < ' tcx >
297+ elem2 : & Place < ' tcx > ,
304298) -> Overlap {
305299 match ( elem1, elem2) {
306300 ( Place :: Local ( l1) , Place :: Local ( l2) ) => {
@@ -318,8 +312,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>(
318312 if static1. def_id != static2. def_id {
319313 debug ! ( "place_element_conflict: DISJOINT-STATIC" ) ;
320314 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 ) {
323316 // We ignore mutable statics - they can only be unsafe code.
324317 debug ! ( "place_element_conflict: IGNORE-STATIC-MUT" ) ;
325318 Overlap :: Disjoint
@@ -397,10 +390,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>(
397390 | ( ProjectionElem :: Index ( ..) , ProjectionElem :: ConstantIndex { .. } )
398391 | ( ProjectionElem :: Index ( ..) , ProjectionElem :: Subslice { .. } )
399392 | ( ProjectionElem :: ConstantIndex { .. } , ProjectionElem :: Index ( ..) )
400- | (
401- ProjectionElem :: ConstantIndex { .. } ,
402- ProjectionElem :: ConstantIndex { .. } ,
403- )
393+ | ( ProjectionElem :: ConstantIndex { .. } , ProjectionElem :: ConstantIndex { .. } )
404394 | ( ProjectionElem :: ConstantIndex { .. } , ProjectionElem :: Subslice { .. } )
405395 | ( ProjectionElem :: Subslice { .. } , ProjectionElem :: Index ( ..) )
406396 | ( ProjectionElem :: Subslice { .. } , ProjectionElem :: ConstantIndex { .. } )
0 commit comments