@@ -3,7 +3,7 @@ use std::mem;
3
3
use either:: { Left , Right } ;
4
4
5
5
use rustc_hir:: def:: DefKind ;
6
- use rustc_middle:: mir:: interpret:: { ErrorHandled , InterpErrorInfo } ;
6
+ use rustc_middle:: mir:: interpret:: ErrorHandled ;
7
7
use rustc_middle:: mir:: pretty:: write_allocation_bytes;
8
8
use rustc_middle:: mir:: { self , ConstAlloc , ConstValue } ;
9
9
use rustc_middle:: traits:: Reveal ;
@@ -19,8 +19,8 @@ use crate::errors;
19
19
use crate :: errors:: ConstEvalError ;
20
20
use crate :: interpret:: eval_nullary_intrinsic;
21
21
use crate :: interpret:: {
22
- intern_const_alloc_recursive, CtfeValidationMode , GlobalId , Immediate , InternKind , InterpCx ,
23
- InterpError , InterpResult , MPlaceTy , MemoryKind , OpTy , RefTracking , StackPopCleanup ,
22
+ intern_const_alloc_recursive, GlobalId , Immediate , InternKind , InterpCx , InterpError ,
23
+ InterpResult , MPlaceTy , MemoryKind , OpTy , StackPopCleanup ,
24
24
} ;
25
25
26
26
// Returns a pointer to where the result lives
@@ -331,25 +331,8 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
331
331
Ok ( mplace) => {
332
332
// Since evaluation had no errors, validate the resulting constant.
333
333
// This is a separate `try` block to provide more targeted error reporting.
334
- let validation: Result < _ , InterpErrorInfo < ' _ > > = try {
335
- let mut ref_tracking = RefTracking :: new ( mplace. clone ( ) ) ;
336
- let mut inner = false ;
337
- while let Some ( ( mplace, path) ) = ref_tracking. todo . pop ( ) {
338
- let mode = if is_static {
339
- if cid. promoted . is_some ( ) {
340
- // Promoteds in statics are allowed to point to statics.
341
- CtfeValidationMode :: Const { inner, allow_static_ptrs : true }
342
- } else {
343
- // a `static`
344
- CtfeValidationMode :: Regular
345
- }
346
- } else {
347
- CtfeValidationMode :: Const { inner, allow_static_ptrs : false }
348
- } ;
349
- ecx. const_validate_operand ( & mplace. into ( ) , path, & mut ref_tracking, mode) ?;
350
- inner = true ;
351
- }
352
- } ;
334
+ let validation = ecx. const_validate_mplace ( & mplace, is_static, cid. promoted . is_some ( ) ) ;
335
+
353
336
let alloc_id = mplace. ptr ( ) . provenance . unwrap ( ) ;
354
337
355
338
// Validation failed, report an error.
0 commit comments