@@ -298,15 +298,15 @@ pub trait InterpretationResult<'tcx>: Sized {
298
298
mplace : & MPlaceTy < ' tcx > ,
299
299
ecx : & mut InterpCx < ' mir , ' tcx , CompileTimeInterpreter < ' mir , ' tcx > > ,
300
300
cid : GlobalId < ' tcx > ,
301
- ) -> InterpResult < ' tcx , Self > ;
301
+ ) -> Result < Self , ErrorHandled > ;
302
302
}
303
303
304
304
impl < ' tcx > InterpretationResult < ' tcx > for ConstAlloc < ' tcx > {
305
305
fn make_result < ' mir > (
306
306
mplace : & MPlaceTy < ' tcx > ,
307
307
ecx : & mut InterpCx < ' mir , ' tcx , CompileTimeInterpreter < ' mir , ' tcx > > ,
308
308
cid : GlobalId < ' tcx > ,
309
- ) -> InterpResult < ' tcx , Self > {
309
+ ) -> Result < Self , ErrorHandled > {
310
310
const_validate_mplace ( ecx, mplace, cid) ?;
311
311
Ok ( ConstAlloc {
312
312
alloc_id : mplace. ptr ( ) . provenance . unwrap ( ) . alloc_id ( ) ,
@@ -399,13 +399,7 @@ fn eval_in_interpreter<'mir, 'tcx, R: InterpretationResult<'tcx>>(
399
399
}
400
400
Ok ( mplace) => {
401
401
// Since evaluation had no errors, validate the resulting constant.
402
- let res = R :: make_result ( & mplace, ecx, cid) ;
403
-
404
- // Validation failed, report an error.
405
- res. map_err ( |error| {
406
- let alloc_id = mplace. ptr ( ) . provenance . unwrap ( ) . alloc_id ( ) ;
407
- const_report_error ( & ecx, error, alloc_id)
408
- } )
402
+ R :: make_result ( & mplace, ecx, cid)
409
403
}
410
404
}
411
405
}
@@ -415,7 +409,8 @@ pub fn const_validate_mplace<'mir, 'tcx>(
415
409
ecx : & InterpCx < ' mir , ' tcx , CompileTimeInterpreter < ' mir , ' tcx > > ,
416
410
mplace : & MPlaceTy < ' tcx > ,
417
411
cid : GlobalId < ' tcx > ,
418
- ) -> InterpResult < ' tcx > {
412
+ ) -> Result < ( ) , ErrorHandled > {
413
+ let alloc_id = mplace. ptr ( ) . provenance . unwrap ( ) . alloc_id ( ) ;
419
414
let mut ref_tracking = RefTracking :: new ( mplace. clone ( ) ) ;
420
415
let mut inner = false ;
421
416
while let Some ( ( mplace, path) ) = ref_tracking. todo . pop ( ) {
@@ -429,7 +424,8 @@ pub fn const_validate_mplace<'mir, 'tcx>(
429
424
CtfeValidationMode :: Const { allow_immutable_unsafe_cell }
430
425
}
431
426
} ;
432
- ecx. const_validate_operand ( & mplace. into ( ) , path, & mut ref_tracking, mode) ?;
427
+ ecx. const_validate_operand ( & mplace. into ( ) , path, & mut ref_tracking, mode)
428
+ . map_err ( |error| const_report_error ( & ecx, error, alloc_id) ) ?;
433
429
inner = true ;
434
430
}
435
431
0 commit comments