@@ -831,8 +831,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
831831
832832 // Normalize consts in writeback, because GCE doesn't normalize eagerly.
833833 if tcx. features ( ) . generic_const_exprs ( ) {
834- value =
835- value. fold_with ( & mut EagerlyNormalizeConsts { tcx, param_env : self . fcx . param_env } ) ;
834+ value = value. fold_with ( & mut EagerlyNormalizeConsts :: new ( self . fcx ) ) ;
836835 }
837836
838837 value
@@ -873,16 +872,22 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
873872
874873struct EagerlyNormalizeConsts < ' tcx > {
875874 tcx : TyCtxt < ' tcx > ,
876- param_env : ty:: ParamEnv < ' tcx > ,
875+ typing_env : ty:: TypingEnv < ' tcx > ,
877876}
877+ impl < ' tcx > EagerlyNormalizeConsts < ' tcx > {
878+ fn new ( fcx : & FnCtxt < ' _ , ' tcx > ) -> Self {
879+ // FIXME(#132279, generic_const_exprs): Using `try_normalize_erasing_regions` here
880+ // means we can't handle opaque types in their defining scope.
881+ EagerlyNormalizeConsts { tcx : fcx. tcx , typing_env : fcx. typing_env ( fcx. param_env ) }
882+ }
883+ }
884+
878885impl < ' tcx > TypeFolder < TyCtxt < ' tcx > > for EagerlyNormalizeConsts < ' tcx > {
879886 fn cx ( & self ) -> TyCtxt < ' tcx > {
880887 self . tcx
881888 }
882889
883890 fn fold_const ( & mut self , ct : ty:: Const < ' tcx > ) -> ty:: Const < ' tcx > {
884- self . tcx
885- . try_normalize_erasing_regions ( ty:: TypingEnv :: from_param_env ( self . param_env ) , ct)
886- . unwrap_or ( ct)
891+ self . tcx . try_normalize_erasing_regions ( self . typing_env , ct) . unwrap_or ( ct)
887892 }
888893}
0 commit comments