@@ -396,16 +396,9 @@ fn eval_in_interpreter<'mir, 'tcx, R: InterpretationResult<'tcx>>(
396
396
}
397
397
Ok ( mplace) => {
398
398
// Since evaluation had no errors, validate the resulting constant.
399
+ const_validate_mplace ( & ecx, & mplace, cid) ?;
399
400
400
- let res = const_validate_mplace ( & ecx, & mplace, cid) ;
401
-
402
- // Validation failed, report an error.
403
- if let Err ( error) = res {
404
- let alloc_id = mplace. ptr ( ) . provenance . unwrap ( ) . alloc_id ( ) ;
405
- Err ( const_report_error ( & ecx, error, alloc_id) )
406
- } else {
407
- Ok ( R :: make_result ( mplace, ecx) )
408
- }
401
+ Ok ( R :: make_result ( mplace, ecx) )
409
402
}
410
403
}
411
404
}
@@ -415,7 +408,8 @@ pub fn const_validate_mplace<'mir, 'tcx>(
415
408
ecx : & InterpCx < ' mir , ' tcx , CompileTimeInterpreter < ' mir , ' tcx > > ,
416
409
mplace : & MPlaceTy < ' tcx > ,
417
410
cid : GlobalId < ' tcx > ,
418
- ) -> InterpResult < ' tcx > {
411
+ ) -> Result < ( ) , ErrorHandled > {
412
+ let alloc_id = mplace. ptr ( ) . provenance . unwrap ( ) . alloc_id ( ) ;
419
413
let mut ref_tracking = RefTracking :: new ( mplace. clone ( ) ) ;
420
414
let mut inner = false ;
421
415
while let Some ( ( mplace, path) ) = ref_tracking. todo . pop ( ) {
@@ -429,7 +423,8 @@ pub fn const_validate_mplace<'mir, 'tcx>(
429
423
CtfeValidationMode :: Const { allow_immutable_unsafe_cell : !inner }
430
424
}
431
425
} ;
432
- ecx. const_validate_operand ( & mplace. into ( ) , path, & mut ref_tracking, mode) ?;
426
+ ecx. const_validate_operand ( & mplace. into ( ) , path, & mut ref_tracking, mode)
427
+ . map_err ( |error| const_report_error ( & ecx, error, alloc_id) ) ?;
433
428
inner = true ;
434
429
}
435
430
0 commit comments