File tree 2 files changed +7
-19
lines changed
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> {
1464
1464
/// If MirPhase >= Derefered and if projection contains Deref,
1465
1465
/// It's guaranteed to be in the first place
1466
1466
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 )
1472
1468
}
1473
1469
1474
1470
/// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
@@ -1546,11 +1542,7 @@ impl<'tcx> PlaceRef<'tcx> {
1546
1542
/// If MirPhase >= Derefered and if projection contains Deref,
1547
1543
/// It's guaranteed to be in the first place
1548
1544
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 )
1554
1546
}
1555
1547
1556
1548
/// 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;
15
15
/// (Concurrent accesses by other threads are no problem as these are anyway non-atomic
16
16
/// copies. Data races are UB.)
17
17
fn 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 ( )
25
21
}
26
22
27
23
/// Determine whether this type may contain a reference (or box), and thus needs retagging.
@@ -82,8 +78,8 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
82
78
} ;
83
79
let place_base_raw = |place : & Place < ' tcx > | {
84
80
// 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 ;
87
83
ty. is_unsafe_ptr ( )
88
84
} else {
89
85
// Not a deref, and thus not raw.
You can’t perform that action at this time.
0 commit comments