@@ -2162,7 +2162,7 @@ pub(super) fn check_type_bounds<'tcx>(
2162
2162
impl_ty : ty:: AssocItem ,
2163
2163
impl_trait_ref : ty:: TraitRef < ' tcx > ,
2164
2164
) -> Result < ( ) , ErrorGuaranteed > {
2165
- let param_env = param_env_with_gat_bounds ( tcx, impl_ty, impl_trait_ref ) ;
2165
+ let param_env = tcx. param_env ( impl_ty. def_id ) ;
2166
2166
debug ! ( ?param_env) ;
2167
2167
2168
2168
let container_id = impl_ty. container_id ( tcx) ;
@@ -2217,8 +2217,14 @@ pub(super) fn check_type_bounds<'tcx>(
2217
2217
. collect ( ) ;
2218
2218
debug ! ( "check_type_bounds: item_bounds={:?}" , obligations) ;
2219
2219
2220
+ // Normalize predicates with the assumption that the GAT may always normalize
2221
+ // to its definition type. This should be the param-env we use to *prove* the
2222
+ // predicate too, but we don't do that because of performance issues.
2223
+ // See <https://github.com/rust-lang/rust/pull/117542#issue-1976337685>.
2224
+ let normalize_param_env = param_env_with_gat_bounds ( tcx, impl_ty, impl_trait_ref) ;
2220
2225
for mut obligation in util:: elaborate ( tcx, obligations) {
2221
- let normalized_predicate = ocx. normalize ( & normalize_cause, param_env, obligation. predicate ) ;
2226
+ let normalized_predicate =
2227
+ ocx. normalize ( & normalize_cause, normalize_param_env, obligation. predicate ) ;
2222
2228
debug ! ( "compare_projection_bounds: normalized predicate = {:?}" , normalized_predicate) ;
2223
2229
obligation. predicate = normalized_predicate;
2224
2230
0 commit comments