@@ -1585,9 +1585,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15851585 unevaluated : ty:: Unevaluated < ' tcx > ,
15861586 span : Option < Span > ,
15871587 ) -> EvalToConstValueResult < ' tcx > {
1588- let param_env = self . tcx . erase_regions ( param_env) ;
15891588 let mut substs = unevaluated. substs ( self . tcx ) ;
1590- substs = self . tcx . erase_regions ( substs) ;
15911589 substs = self . resolve_vars_if_possible ( substs) ;
15921590
15931591 // Postpone the evaluation of constants whose substs depend on inference
@@ -1596,15 +1594,18 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15961594 return Err ( ErrorHandled :: TooGeneric ) ;
15971595 }
15981596
1597+ let param_env_erased = self . tcx . erase_regions ( param_env) ;
1598+ let substs_erased = self . tcx . erase_regions ( substs) ;
1599+
15991600 let unevaluated = ty:: Unevaluated {
16001601 def : unevaluated. def ,
1601- substs_ : Some ( substs ) ,
1602+ substs_ : Some ( substs_erased ) ,
16021603 promoted : unevaluated. promoted ,
16031604 } ;
16041605
16051606 // The return value is the evaluated value which doesn't contain any reference to inference
16061607 // variables, thus we don't need to substitute back the original values.
1607- self . tcx . const_eval_resolve ( param_env , unevaluated, span)
1608+ self . tcx . const_eval_resolve ( param_env_erased , unevaluated, span)
16081609 }
16091610
16101611 /// If `typ` is a type variable of some kind, resolve it one level
0 commit comments