@@ -123,6 +123,36 @@ where
123
123
return Err ( NoSolution ) ;
124
124
}
125
125
ecx. probe_trait_candidate ( source) . enter ( |ecx| {
126
+ // FIXME(generic_associated_types): Addresses aggressive inference in #92917.
127
+ //
128
+ // If this type is a GAT with currently unconstrained arguments, we do not
129
+ // want to normalize it via a candidate which only applies for a specific
130
+ // instantiation. We could otherwise keep the GAT as rigid and succeed this way.
131
+ // See tests/ui/generic-associated-types/no-incomplete-gat-arg-inference.rs.
132
+ //
133
+ // This only avoids normalization if the GAT arguments are fully unconstrained.
134
+ // This is quite arbitrary but fixing it causes some ambiguity, see #125196.
135
+ match goal. predicate . alias . kind ( cx) {
136
+ ty:: AliasTermKind :: ProjectionTy | ty:: AliasTermKind :: ProjectionConst => {
137
+ for arg in goal. predicate . alias . own_args ( cx) . iter ( ) {
138
+ let Some ( term) = arg. as_term ( ) else {
139
+ continue ;
140
+ } ;
141
+ let term = ecx. structurally_normalize_term ( goal. param_env , term) ?;
142
+ if term. is_infer ( ) {
143
+ return ecx. evaluate_added_goals_and_make_canonical_response (
144
+ Certainty :: AMBIGUOUS ,
145
+ ) ;
146
+ }
147
+ }
148
+ }
149
+ ty:: AliasTermKind :: OpaqueTy
150
+ | ty:: AliasTermKind :: InherentTy
151
+ | ty:: AliasTermKind :: InherentConst
152
+ | ty:: AliasTermKind :: FreeTy
153
+ | ty:: AliasTermKind :: FreeConst
154
+ | ty:: AliasTermKind :: UnevaluatedConst => { }
155
+ }
126
156
let assumption_projection_pred =
127
157
ecx. instantiate_binder_with_infer ( projection_pred) ;
128
158
ecx. eq (
0 commit comments