From d0aedfbb900309bb633b3ba04bf008183cfdd9a7 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 31 Aug 2024 11:29:02 +0200 Subject: interpret, codegen: tweak some comments and checks regarding Box with custom allocator --- compiler/rustc_const_eval/src/interpret/place.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'compiler/rustc_const_eval/src') diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index 2afdd02c880..ede6a51c712 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -438,14 +438,16 @@ where &self, src: &impl Readable<'tcx, M::Provenance>, ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::Provenance>> { + if src.layout().ty.is_box() { + // Derefer should have removed all Box derefs. + // Some `Box` are not immediates (if they have a custom allocator) + // so the code below would fail. + bug!("dereferencing {}", src.layout().ty); + } + let val = self.read_immediate(src)?; trace!("deref to {} on {:?}", val.layout.ty, *val); - if val.layout.ty.is_box() { - // Derefer should have removed all Box derefs - bug!("dereferencing {}", val.layout.ty); - } - let mplace = self.ref_to_mplace(&val)?; Ok(mplace) } -- cgit 1.4.1-3-g733a5