Skip to content

Commit a3fa705

Browse files
committed
Rename some things around validation error reporting to signal that it is in fact about validation failures
1 parent 2a1a6fa commit a3fa705

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ fn eval_in_interpreter<'tcx, R: InterpretationResult<'tcx>>(
382382
}
383383

384384
#[inline(always)]
385-
pub fn const_validate_mplace<'mir, 'tcx>(
385+
fn const_validate_mplace<'mir, 'tcx>(
386386
ecx: &InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
387387
mplace: &MPlaceTy<'tcx>,
388388
cid: GlobalId<'tcx>,
@@ -402,15 +402,17 @@ pub fn const_validate_mplace<'mir, 'tcx>(
402402
}
403403
};
404404
ecx.const_validate_operand(&mplace.into(), path, &mut ref_tracking, mode)
405-
.map_err(|error| const_report_error(&ecx, error, alloc_id))?;
405+
// Instead of just reporting the `InterpError` via the usual machinery, we give a more targetted
406+
// error about the validation failure.
407+
.map_err(|error| report_validation_error(&ecx, error, alloc_id))?;
406408
inner = true;
407409
}
408410

409411
Ok(())
410412
}
411413

412414
#[inline(always)]
413-
pub fn const_report_error<'mir, 'tcx>(
415+
fn report_validation_error<'mir, 'tcx>(
414416
ecx: &InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
415417
error: InterpErrorInfo<'tcx>,
416418
alloc_id: AllocId,
@@ -429,6 +431,6 @@ pub fn const_report_error<'mir, 'tcx>(
429431
error,
430432
None,
431433
|| crate::const_eval::get_span_and_frames(ecx.tcx, ecx.stack()),
432-
move |span, frames| errors::UndefinedBehavior { span, ub_note, frames, raw_bytes },
434+
move |span, frames| errors::ValidationFailure { span, ub_note, frames, raw_bytes },
433435
)
434436
}

compiler/rustc_const_eval/src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ pub struct NullaryIntrinsicError {
410410

411411
#[derive(Diagnostic)]
412412
#[diag(const_eval_undefined_behavior, code = E0080)]
413-
pub struct UndefinedBehavior {
413+
pub struct ValidationFailure {
414414
#[primary_span]
415415
pub span: Span,
416416
#[note(const_eval_undefined_behavior_note)]

0 commit comments

Comments
 (0)