fn is_stable(
place: PlaceRef<'_, '_>,
) -> bool {
- if let Some(proj) = &place.projection {
- match proj.elem {
+ place.projection.iter().all(|elem| {
+ match elem {
// Which place this evaluates to can change with any memory write,
// so cannot assume this to be stable.
- ProjectionElem::Deref =>
- false,
+ ProjectionElem::Deref => false,
// Array indices are intersting, but MIR building generates a *fresh*
// temporary for every array access, so the index cannot be changed as
// a side-effect.
ProjectionElem::Field { .. } |
ProjectionElem::ConstantIndex { .. } |
ProjectionElem::Subslice { .. } |
- ProjectionElem::Downcast { .. } =>
- is_stable(PlaceRef {
- base: place.base,
- projection: &proj.base,
- }),
+ ProjectionElem::Downcast { .. } => true,
}
- } else {
- true
- }
+ })
}
/// Determine whether this type may be a reference (or box), and thus needs retagging.
}
}
-impl MirPass for AddRetag {
- fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
+impl<'tcx> MirPass<'tcx> for AddRetag {
+ fn run_pass(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
if !tcx.sess.opts.debugging_opts.mir_emit_retag {
return;
}