@@ -831,8 +831,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
831
831
832
832
// Normalize consts in writeback, because GCE doesn't normalize eagerly.
833
833
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 ) ) ;
836
835
}
837
836
838
837
value
@@ -873,16 +872,22 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
873
872
874
873
struct EagerlyNormalizeConsts < ' tcx > {
875
874
tcx : TyCtxt < ' tcx > ,
876
- param_env : ty:: ParamEnv < ' tcx > ,
875
+ typing_env : ty:: TypingEnv < ' tcx > ,
877
876
}
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
+
878
885
impl < ' tcx > TypeFolder < TyCtxt < ' tcx > > for EagerlyNormalizeConsts < ' tcx > {
879
886
fn cx ( & self ) -> TyCtxt < ' tcx > {
880
887
self . tcx
881
888
}
882
889
883
890
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)
887
892
}
888
893
}
0 commit comments