@@ -227,12 +227,11 @@ pub fn intern_const_alloc_recursive<'tcx, M: CompileTimeMachine<'tcx, const_eval
227227
228228    // Keep interning as long as there are things to intern.
229229    // We show errors if there are dangling pointers, or mutable pointers in immutable contexts
230-     // (i.e., everything except for `static mut`). When these errors affect references, it is
231-     // unfortunate that we show these errors here and not during validation, since validation can
232-     // show much nicer errors. However, we do need these checks to be run on all pointers, including
233-     // raw pointers, so we cannot rely on validation to catch them -- and since interning runs
234-     // before validation, and interning doesn't know the type of anything, this means we can't show
235-     // better errors. Maybe we should consider doing validation before interning in the future.
230+     // (i.e., everything except for `static mut`). We only return these errors as a `Result`
231+     // so that the caller can run validation, and subsequently only report interning errors
232+     // if validation fails. Validation has the better error messages so we prefer those, but
233+     // interning has better coverage since it "sees" *all* pointers, including raw pointers and
234+     // references stored in unions.
236235    while let Some(prov) = todo.pop() {
237236        trace!(?prov);
238237        let alloc_id = prov.alloc_id();
@@ -279,12 +278,12 @@ pub fn intern_const_alloc_recursive<'tcx, M: CompileTimeMachine<'tcx, const_eval
279278            // when there is memory there that someone might expect to be mutable, but we make it immutable.
280279            let dangling = !is_already_global && !ecx.memory.alloc_map.contains_key(&alloc_id);
281280            if !dangling {
282-                 // Found a mutable reference  inside a const where inner allocations should be
281+                 // Found a mutable pointer  inside a const where inner allocations should be
283282                // immutable.
284283                if !ecx.tcx.sess.opts.unstable_opts.unleash_the_miri_inside_of_you {
285284                    span_bug!(
286285                        ecx.tcx.span,
287-                         "the static const safety checks accepted mutable references  they should not have accepted"
286+                         "the static const safety checks accepted a  mutable pointer  they should not have accepted"
288287                    );
289288                }
290289                // Prefer dangling pointer errors over mutable pointer errors
0 commit comments