@@ -393,19 +393,9 @@ fn eval_in_interpreter<'mir, 'tcx, R: InterpretationResult<'tcx>>(
393
393
}
394
394
Ok ( mplace) => {
395
395
// Since evaluation had no errors, validate the resulting constant.
396
+ const_validate_mplace ( & ecx, & mplace, cid) ?;
396
397
397
- // Temporarily allow access to the static_root_ids for the purpose of validation.
398
- let static_root_ids = ecx. machine . static_root_ids . take ( ) ;
399
- let res = const_validate_mplace ( & ecx, & mplace, cid) ;
400
- ecx. machine . static_root_ids = static_root_ids;
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
- }
398
+ Ok ( R :: make_result ( mplace, ecx) )
409
399
}
410
400
}
411
401
}
@@ -415,7 +405,8 @@ pub fn const_validate_mplace<'mir, 'tcx>(
415
405
ecx : & InterpCx < ' mir , ' tcx , CompileTimeInterpreter < ' mir , ' tcx > > ,
416
406
mplace : & MPlaceTy < ' tcx > ,
417
407
cid : GlobalId < ' tcx > ,
418
- ) -> InterpResult < ' tcx > {
408
+ ) -> Result < ( ) , ErrorHandled > {
409
+ let alloc_id = mplace. ptr ( ) . provenance . unwrap ( ) . alloc_id ( ) ;
419
410
let mut ref_tracking = RefTracking :: new ( mplace. clone ( ) ) ;
420
411
let mut inner = false ;
421
412
while let Some ( ( mplace, path) ) = ref_tracking. todo . pop ( ) {
@@ -429,7 +420,8 @@ pub fn const_validate_mplace<'mir, 'tcx>(
429
420
CtfeValidationMode :: Const { allow_immutable_unsafe_cell : !inner }
430
421
}
431
422
} ;
432
- ecx. const_validate_operand ( & mplace. into ( ) , path, & mut ref_tracking, mode) ?;
423
+ ecx. const_validate_operand ( & mplace. into ( ) , path, & mut ref_tracking, mode)
424
+ . map_err ( |error| const_report_error ( & ecx, error, alloc_id) ) ?;
433
425
inner = true ;
434
426
}
435
427
0 commit comments