Skip to content

Commit 2af0dd0

Browse files
committed
Rewrite place workflow in rustc_mir/util
1 parent 9ec03b3 commit 2af0dd0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Diff for: src/librustc_mir/util/alignment.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,21 @@ fn is_within_packed<'a, 'tcx, L>(
5252
where
5353
L: HasLocalDecls<'tcx>,
5454
{
55-
if !place.elems.is_empty() {
56-
for (i, elem) in place.elems.iter().cloned().enumerate().rev() {
55+
if !place.has_no_projection() {
56+
let mut base_ty = place.base.ty(local_decls);
57+
for elem in place.elems.iter() {
5758
match elem {
5859
// encountered a Deref, which is ABI-aligned
5960
ProjectionElem::Deref => break,
6061
ProjectionElem::Field(..) => {
61-
let base_place = place.elem_base(tcx, i);
62-
let ty = base_place.ty(local_decls, tcx).to_ty(tcx);
63-
match ty.sty {
62+
match base_ty.sty {
6463
ty::TyAdt(def, _) if def.repr.packed() => return true,
65-
_ => continue,
64+
_ => {},
6665
}
6766
}
68-
_ => continue,
67+
_ => {},
6968
}
69+
base_ty = tcx::PlaceTy::from(base_ty).projection_ty(tcx, elem).to_ty(tcx);
7070
}
7171
}
7272

0 commit comments

Comments
 (0)