From 38a7438f3c1f9a83daed9dcba09db0c744a0f137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20A=C4=9Fcayaz=C4=B1?= Date: Wed, 4 Oct 2023 17:25:57 +0300 Subject: [PATCH] fix normalization of ZST --- compiler/rustc_smir/src/rustc_smir/alloc.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_smir/alloc.rs b/compiler/rustc_smir/src/rustc_smir/alloc.rs index 63a2a145069ee..20a6fd0bf98a6 100644 --- a/compiler/rustc_smir/src/rustc_smir/alloc.rs +++ b/compiler/rustc_smir/src/rustc_smir/alloc.rs @@ -41,8 +41,18 @@ pub fn new_allocation<'tcx>( allocation.stable(tables) } ConstValue::ZeroSized => { - let align = - tables.tcx.layout_of(rustc_middle::ty::ParamEnv::empty().and(ty)).unwrap().align; + let mut ty = ty; + match ty.kind() { + rustc_middle::ty::FnDef(def, _) => { + ty = tables.tcx.type_of(def).skip_binder(); + } + _ => (), + } + let align = tables + .tcx + .layout_of(rustc_middle::ty::ParamEnv::reveal_all().and(ty)) + .unwrap() + .align; new_empty_allocation(align.abi) } ConstValue::Slice { data, meta } => {