Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions compiler/rustc_const_eval/src/interpret/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
interp_ok(true)
}
}
// Types that are considered transparent in `unfold_transparent` should also act
// like transparent types here.
ty::Pat(base, _) => self.has_trivial_abi(self.layout_of(base)?),
ty::UnsafeBinder(bound_ty) => {
let ty = self.tcx.instantiate_bound_regions_with_erased(bound_ty.into());
self.has_trivial_abi(self.layout_of(ty)?)
}

ty::Alias(..) => panic!("non-normalized type"),
_ => interp_ok(false),
Expand All @@ -116,8 +123,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
layout: TyAndLayout<'tcx>,
may_unfold: impl Fn(AdtDef<'tcx>) -> bool,
) -> InterpResult<'tcx, TyAndLayout<'tcx>> {
match layout.ty.kind() {
ty::Adt(adt_def, _) if adt_def.repr().transparent() && may_unfold(*adt_def) => {
match *layout.ty.kind() {
ty::Adt(adt_def, _) if adt_def.repr().transparent() && may_unfold(adt_def) => {
assert_matches!(layout.variants, rustc_abi::Variants::Single { .. });
// Look for non-trivial-ABI field(s).
let mut found = None;
Expand All @@ -142,7 +149,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
// Recurse.
self.unfold_transparent(field, may_unfold)
}
ty::Pat(base, _) => interp_ok(self.layout_of(*base)?),
ty::Pat(base, _) => self.unfold_transparent(self.layout_of(base)?, may_unfold),
ty::UnsafeBinder(bound_ty) => {
let ty = self.tcx.instantiate_bound_regions_with_erased(bound_ty.into());
self.unfold_transparent(self.layout_of(ty)?, may_unfold)
}
// Not a transparent type, no further unfolding.
_ => interp_ok(layout),
}
Expand Down
Loading