@@ -382,7 +382,7 @@ fn eval_in_interpreter<'tcx, R: InterpretationResult<'tcx>>(
382
382
}
383
383
384
384
#[ inline( always) ]
385
- pub fn const_validate_mplace < ' mir , ' tcx > (
385
+ fn const_validate_mplace < ' mir , ' tcx > (
386
386
ecx : & InterpCx < ' mir , ' tcx , CompileTimeInterpreter < ' mir , ' tcx > > ,
387
387
mplace : & MPlaceTy < ' tcx > ,
388
388
cid : GlobalId < ' tcx > ,
@@ -402,15 +402,17 @@ pub fn const_validate_mplace<'mir, 'tcx>(
402
402
}
403
403
} ;
404
404
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) ) ?;
406
408
inner = true ;
407
409
}
408
410
409
411
Ok ( ( ) )
410
412
}
411
413
412
414
#[ inline( always) ]
413
- pub fn const_report_error < ' mir , ' tcx > (
415
+ fn report_validation_error < ' mir , ' tcx > (
414
416
ecx : & InterpCx < ' mir , ' tcx , CompileTimeInterpreter < ' mir , ' tcx > > ,
415
417
error : InterpErrorInfo < ' tcx > ,
416
418
alloc_id : AllocId ,
@@ -429,6 +431,6 @@ pub fn const_report_error<'mir, 'tcx>(
429
431
error,
430
432
None ,
431
433
|| 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 } ,
433
435
)
434
436
}
0 commit comments