@@ -6,10 +6,11 @@ use rustc_errors::{EmissionGuarantee, MultiSpan};
6
6
use rustc_hir:: def_id:: CrateNum ;
7
7
use rustc_hir:: LangItem ;
8
8
use rustc_middle:: mir:: { self , Body , TerminatorKind } ;
9
- use rustc_middle:: ty:: { self , GenericArgs , Instance , ParamEnv , ParamEnvAnd , Ty } ;
9
+ use rustc_middle:: ty:: { self , GenericArgs , Instance , ParamEnv , ParamEnvAnd , Ty , TypingMode } ;
10
10
use rustc_mir_dataflow:: lattice:: MeetSemiLattice ;
11
11
use rustc_mir_dataflow:: Analysis ;
12
12
use rustc_span:: DUMMY_SP ;
13
+ use rustc_trait_selection:: infer:: TyCtxtInferExt ;
13
14
14
15
use super :: dataflow:: AdjustmentComputation ;
15
16
use super :: { AdjustmentBounds , Error , ExpectationRange , PolyDisplay , UseSite , UseSiteKind } ;
@@ -423,8 +424,8 @@ impl<'tcx> AnalysisCtxt<'tcx> {
423
424
}
424
425
425
426
let elem_adj = self . drop_adjustment ( param_and_elem_ty) ?;
426
- let size = size
427
- . normalize_internal ( self . tcx , param_env)
427
+ let infcx = self . tcx . infer_ctxt ( ) . build ( TypingMode :: PostAnalysis ) ;
428
+ let size = rustc_trait_selection :: traits :: evaluate_const ( & infcx , * size , param_env)
428
429
. try_to_target_usize ( self . tcx )
429
430
. ok_or ( Error :: TooGeneric ) ?;
430
431
let Ok ( size) = i32:: try_from ( size) else {
@@ -741,8 +742,8 @@ memoize!(
741
742
}
742
743
743
744
ty:: Array ( elem_ty, size) => {
744
- let size = size
745
- . normalize_internal ( cx . tcx , param_env)
745
+ let infcx = cx . tcx . infer_ctxt ( ) . build ( TypingMode :: PostAnalysis ) ;
746
+ let size = rustc_trait_selection :: traits :: evaluate_const ( & infcx , * size , param_env)
746
747
. try_to_target_usize( cx. tcx)
747
748
. ok_or( Error :: TooGeneric ) ;
748
749
if size == Ok ( 0 ) {
0 commit comments