File tree Expand file tree Collapse file tree 2 files changed +7
-19
lines changed Expand file tree Collapse file tree 2 files changed +7
-19
lines changed Original file line number Diff line number Diff line change @@ -1464,11 +1464,7 @@ impl<'tcx> Place<'tcx> {
14641464 /// If MirPhase >= Derefered and if projection contains Deref,
14651465 /// It's guaranteed to be in the first place
14661466 pub fn has_deref ( & self ) -> bool {
1467- if !self . projection . is_empty ( ) && self . projection [ 0 ] == PlaceElem :: Deref {
1468- true
1469- } else {
1470- false
1471- }
1467+ self . projection . first ( ) == Some ( & PlaceElem :: Deref )
14721468 }
14731469
14741470 /// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
@@ -1546,11 +1542,7 @@ impl<'tcx> PlaceRef<'tcx> {
15461542 /// If MirPhase >= Derefered and if projection contains Deref,
15471543 /// It's guaranteed to be in the first place
15481544 pub fn has_deref ( & self ) -> bool {
1549- if !self . projection . is_empty ( ) && self . projection [ 0 ] == PlaceElem :: Deref {
1550- true
1551- } else {
1552- false
1553- }
1545+ self . projection . first ( ) == Some ( & PlaceElem :: Deref )
15541546 }
15551547
15561548 /// If this place represents a local variable like `_X` with no
Original file line number Diff line number Diff line change @@ -15,13 +15,9 @@ pub struct AddRetag;
1515/// (Concurrent accesses by other threads are no problem as these are anyway non-atomic
1616/// copies. Data races are UB.)
1717fn is_stable ( place : PlaceRef < ' _ > ) -> bool {
18- if place. has_deref ( ) {
19- // Which place this evaluates to can change with any memory write,
20- // so cannot assume deref to be stable.
21- return false ;
22- } else {
23- return true ;
24- }
18+ // Which place this evaluates to can change with any memory write,
19+ // so cannot assume deref to be stable.
20+ !place. has_deref ( )
2521}
2622
2723/// Determine whether this type may contain a reference (or box), and thus needs retagging.
@@ -82,8 +78,8 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
8278 } ;
8379 let place_base_raw = |place : & Place < ' tcx > | {
8480 // If this is a `Deref`, get the type of what we are deref'ing.
85- if place. ret_deref ( ) . is_some ( ) {
86- let ty = place. ty ( local_decls , tcx ) . ty ;
81+ if place. has_deref ( ) {
82+ let ty = & local_decls [ place. local ] . ty ;
8783 ty. is_unsafe_ptr ( )
8884 } else {
8985 // Not a deref, and thus not raw.
You can’t perform that action at this time.
0 commit comments