X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_mir%2Ftransform%2Fadd_retag.rs;h=466f6060827ec1d7b15f95538157982bfbb841e0;hb=e9c41148c0c834d13d6f45bfd99c8f23781c5d31;hp=0fd75cd57b2ac31856938a2707fa59b1274ea986;hpb=555d7a2fd6165b614cfc01136d8e3f5c465a1582;p=rust.git diff --git a/src/librustc_mir/transform/add_retag.rs b/src/librustc_mir/transform/add_retag.rs index 0fd75cd57b2..466f6060827 100644 --- a/src/librustc_mir/transform/add_retag.rs +++ b/src/librustc_mir/transform/add_retag.rs @@ -17,12 +17,11 @@ 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. @@ -31,15 +30,9 @@ fn is_stable( 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.