|
16 | 16 |
|
17 | 17 | use super::validity::RefTracking;
|
18 | 18 | use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
| 19 | +use rustc_errors::ErrorReported; |
19 | 20 | use rustc_hir as hir;
|
20 | 21 | use rustc_middle::mir::interpret::InterpResult;
|
21 | 22 | use rustc_middle::ty::{self, layout::TyAndLayout, Ty};
|
@@ -285,11 +286,13 @@ pub enum InternKind {
|
285 | 286 | /// tracks where in the value we are and thus can show much better error messages.
|
286 | 287 | /// Any errors here would anyway be turned into `const_err` lints, whereas validation failures
|
287 | 288 | /// are hard errors.
|
| 289 | +#[tracing::instrument(skip(ecx))] |
288 | 290 | pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx>>(
|
289 | 291 | ecx: &mut InterpCx<'mir, 'tcx, M>,
|
290 | 292 | intern_kind: InternKind,
|
291 | 293 | ret: MPlaceTy<'tcx>,
|
292 |
| -) where |
| 294 | +) -> Result<(), ErrorReported> |
| 295 | +where |
293 | 296 | 'tcx: 'mir,
|
294 | 297 | {
|
295 | 298 | let tcx = ecx.tcx;
|
@@ -405,12 +408,14 @@ pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx>>(
|
405 | 408 | // Codegen does not like dangling pointers, and generally `tcx` assumes that
|
406 | 409 | // all allocations referenced anywhere actually exist. So, make sure we error here.
|
407 | 410 | ecx.tcx.sess.span_err(ecx.tcx.span, "encountered dangling pointer in final constant");
|
| 411 | + return Err(ErrorReported); |
408 | 412 | } else if ecx.tcx.get_global_alloc(alloc_id).is_none() {
|
409 | 413 | // We have hit an `AllocId` that is neither in local or global memory and isn't
|
410 | 414 | // marked as dangling by local memory. That should be impossible.
|
411 | 415 | span_bug!(ecx.tcx.span, "encountered unknown alloc id {:?}", alloc_id);
|
412 | 416 | }
|
413 | 417 | }
|
| 418 | + Ok(()) |
414 | 419 | }
|
415 | 420 |
|
416 | 421 | impl<'mir, 'tcx: 'mir, M: super::intern::CompileTimeMachine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|
0 commit comments