diff options
| author | Ralf Jung <post@ralfj.de> | 2024-03-05 11:32:03 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-03-05 15:03:33 +0100 |
| commit | f391c0793b443d30ef8c4d4228550439d4dbfead (patch) | |
| tree | a5da4c5407252088c561dc674881cffa5f833fae /compiler/rustc_const_eval/src/interpret | |
| parent | 5a1e5449c8f4cb6b12b4f64238e3c058767ebf02 (diff) | |
| download | rust-f391c0793b443d30ef8c4d4228550439d4dbfead.tar.gz rust-f391c0793b443d30ef8c4d4228550439d4dbfead.zip | |
only set noalias on Box with the global allocator
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/place.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/terminator.rs | 10 |
2 files changed, 3 insertions, 8 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index 6e987784ff9..672008edfd3 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -437,6 +437,7 @@ where 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); } diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs index e72ace8be35..d29e69d753e 100644 --- a/compiler/rustc_const_eval/src/interpret/terminator.rs +++ b/compiler/rustc_const_eval/src/interpret/terminator.rs @@ -359,14 +359,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { Ok(Some(match ty.kind() { ty::Ref(_, ty, _) => *ty, ty::RawPtr(mt) => mt.ty, - // We should only accept `Box` with the default allocator. - // It's hard to test for that though so we accept every 1-ZST allocator. - ty::Adt(def, args) - if def.is_box() - && self.layout_of(args[1].expect_ty()).is_ok_and(|l| l.is_1zst()) => - { - args[0].expect_ty() - } + // We only accept `Box` with the default allocator. + _ if ty.is_box_global(*self.tcx) => ty.boxed_ty(), _ => return Ok(None), })) }; |
