@@ -11,7 +11,6 @@ use rustc_hir::def::{CtorKind, DefKind, Res};
1111use rustc_hir:: pat_util:: EnumerateAndAdjustIterator ;
1212use rustc_hir:: { self as hir, BindingMode , ByRef , HirId , LangItem , Mutability , Pat , PatKind } ;
1313use rustc_infer:: infer;
14- use rustc_middle:: mir:: interpret:: ErrorHandled ;
1514use rustc_middle:: ty:: { self , Ty , TypeVisitableExt } ;
1615use rustc_middle:: { bug, span_bug} ;
1716use rustc_session:: lint:: builtin:: NON_EXHAUSTIVE_OMITTED_PATTERNS ;
@@ -2413,17 +2412,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24132412 len : ty:: Const < ' tcx > ,
24142413 min_len : u64 ,
24152414 ) -> ( Option < Ty < ' tcx > > , Ty < ' tcx > ) {
2416- let len = match len. eval ( self . tcx , self . param_env , span) {
2417- Ok ( ( _, val) ) => val
2418- . try_to_scalar ( )
2419- . and_then ( |scalar| scalar. try_to_scalar_int ( ) . ok ( ) )
2420- . map ( |int| int. to_target_usize ( self . tcx ) ) ,
2421- Err ( ErrorHandled :: Reported ( ..) ) => {
2422- let guar = self . error_scrutinee_unfixed_length ( span) ;
2423- return ( Some ( Ty :: new_error ( self . tcx , guar) ) , arr_ty) ;
2424- }
2425- Err ( ErrorHandled :: TooGeneric ( ..) ) => None ,
2426- } ;
2415+ let len = len. try_eval_target_usize ( self . tcx , self . param_env ) ;
24272416
24282417 let guar = if let Some ( len) = len {
24292418 // Now we know the length...
0 commit comments