has_deref: simpler comparison, ty fix
This commit is contained in:
parent
c3e1e7a947
commit
447aaceed7
2 changed files with 7 additions and 19 deletions
|
@ -1464,11 +1464,7 @@ impl<'tcx> Place<'tcx> {
|
||||||
/// If MirPhase >= Derefered and if projection contains Deref,
|
/// If MirPhase >= Derefered and if projection contains Deref,
|
||||||
/// It's guaranteed to be in the first place
|
/// It's guaranteed to be in the first place
|
||||||
pub fn has_deref(&self) -> bool {
|
pub fn has_deref(&self) -> bool {
|
||||||
if !self.projection.is_empty() && self.projection[0] == PlaceElem::Deref {
|
self.projection.first() == Some(&PlaceElem::Deref)
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
|
/// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
|
||||||
|
@ -1546,11 +1542,7 @@ impl<'tcx> PlaceRef<'tcx> {
|
||||||
/// If MirPhase >= Derefered and if projection contains Deref,
|
/// If MirPhase >= Derefered and if projection contains Deref,
|
||||||
/// It's guaranteed to be in the first place
|
/// It's guaranteed to be in the first place
|
||||||
pub fn has_deref(&self) -> bool {
|
pub fn has_deref(&self) -> bool {
|
||||||
if !self.projection.is_empty() && self.projection[0] == PlaceElem::Deref {
|
self.projection.first() == Some(&PlaceElem::Deref)
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If this place represents a local variable like `_X` with no
|
/// If this place represents a local variable like `_X` with no
|
||||||
|
|
|
@ -15,13 +15,9 @@ pub struct AddRetag;
|
||||||
/// (Concurrent accesses by other threads are no problem as these are anyway non-atomic
|
/// (Concurrent accesses by other threads are no problem as these are anyway non-atomic
|
||||||
/// copies. Data races are UB.)
|
/// copies. Data races are UB.)
|
||||||
fn is_stable(place: PlaceRef<'_>) -> bool {
|
fn is_stable(place: PlaceRef<'_>) -> bool {
|
||||||
if place.has_deref() {
|
// Which place this evaluates to can change with any memory write,
|
||||||
// Which place this evaluates to can change with any memory write,
|
// so cannot assume deref to be stable.
|
||||||
// so cannot assume deref to be stable.
|
!place.has_deref()
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determine whether this type may contain a reference (or box), and thus needs retagging.
|
/// Determine whether this type may contain a reference (or box), and thus needs retagging.
|
||||||
|
@ -82,8 +78,8 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
|
||||||
};
|
};
|
||||||
let place_base_raw = |place: &Place<'tcx>| {
|
let place_base_raw = |place: &Place<'tcx>| {
|
||||||
// If this is a `Deref`, get the type of what we are deref'ing.
|
// If this is a `Deref`, get the type of what we are deref'ing.
|
||||||
if place.ret_deref().is_some() {
|
if place.has_deref() {
|
||||||
let ty = place.ty(local_decls, tcx).ty;
|
let ty = &local_decls[place.local].ty;
|
||||||
ty.is_unsafe_ptr()
|
ty.is_unsafe_ptr()
|
||||||
} else {
|
} else {
|
||||||
// Not a deref, and thus not raw.
|
// Not a deref, and thus not raw.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue