about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret/validity.rs
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-07-16 15:11:11 +0200
committerRalf Jung <post@ralfj.de>2025-07-16 15:29:52 +0200
commit8f854d9cb2d108a2d4f980ccb4d5909e214e6ef0 (patch)
tree96f27edd5f2e963cce5fea17cfacad2a342aa98c /compiler/rustc_const_eval/src/interpret/validity.rs
parentfd48b7b8dd911229b635f7969e6213b5af337b7d (diff)
downloadrust-8f854d9cb2d108a2d4f980ccb4d5909e214e6ef0.tar.gz
rust-8f854d9cb2d108a2d4f980ccb4d5909e214e6ef0.zip
const heap: fix ICE on forgotten make_global
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret/validity.rs')
-rw-r--r--compiler/rustc_const_eval/src/interpret/validity.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs
index fc44490c96d..62f591ceaa9 100644
--- a/compiler/rustc_const_eval/src/interpret/validity.rs
+++ b/compiler/rustc_const_eval/src/interpret/validity.rs
@@ -558,7 +558,15 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
                 {
                     // Everything should be already interned.
                     let Some(global_alloc) = self.ecx.tcx.try_get_global_alloc(alloc_id) else {
-                        assert!(self.ecx.memory.alloc_map.get(alloc_id).is_none());
+                        if self.ecx.memory.alloc_map.contains_key(&alloc_id) {
+                            // This can happen when interning didn't complete due to, e.g.
+                            // missing `make_global`. This must mean other errors are already
+                            // being reported.
+                            self.ecx.tcx.dcx().delayed_bug(
+                                "interning did not complete, there should be an error",
+                            );
+                            return interp_ok(());
+                        }
                         // We can't have *any* references to non-existing allocations in const-eval
                         // as the rest of rustc isn't happy with them... so we throw an error, even
                         // though for zero-sized references this isn't really UB.