@@ -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}
0 commit comments