]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/util/alignment.rs
Rollup merge of #65763 - ObsidianMinor:diag/65642, r=varkor
[rust.git] / src / librustc_mir / util / alignment.rs
index b4c97f91917324e1fdcb9e60587f497e54b595d4..1bad85ec42d08841f8c9c07534b0393863847232 100644 (file)
@@ -38,15 +38,16 @@ fn is_within_packed<'tcx, L>(tcx: TyCtxt<'tcx>, local_decls: &L, place: &Place<'
 where
     L: HasLocalDecls<'tcx>,
 {
-    for (i, elem) in place.projection.iter().enumerate().rev() {
-        let proj_base = &place.projection[..i];
+    let mut cursor = &*place.projection;
+    while let [proj_base @ .., elem] = cursor {
+        cursor = proj_base;
 
         match elem {
             // encountered a Deref, which is ABI-aligned
             ProjectionElem::Deref => break,
             ProjectionElem::Field(..) => {
                 let ty = Place::ty_from(&place.base, proj_base, local_decls, tcx).ty;
-                match ty.sty {
+                match ty.kind {
                     ty::Adt(def, _) if def.repr.packed() => {
                         return true
                     }