Skip to content

Commit

Permalink
Only make GAT ambiguous in match_projection_projections considering s…
Browse files Browse the repository at this point in the history
…hallow resolvability
  • Loading branch information
compiler-errors committed May 17, 2024
1 parent ddba1dc commit ed46830
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1778,9 +1778,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// If this type is a GAT, and of the GAT args resolve to something new,
// that means that we must have newly inferred something about the GAT.
// We should give up in that case.
// FIXME(generic-associated-types): This only detects one layer of inference,
// which is probably not what we actually want, but fixing it causes some ambiguity:
// <https://github.com/rust-lang/rust/issues/125196>.
if !generics.own_params.is_empty()
&& obligation.predicate.args[generics.parent_count..].iter().any(|&p| {
p.has_non_region_infer() && self.infcx.resolve_vars_if_possible(p) != p
p.has_non_region_infer()
&& match p.unpack() {
ty::GenericArgKind::Const(ct) => {
self.infcx.shallow_resolve_const(ct) != ct
}
ty::GenericArgKind::Type(ty) => self.infcx.shallow_resolve(ty) != ty,
ty::GenericArgKind::Lifetime(_) => false,
}
})
{
ProjectionMatchesProjection::Ambiguous
Expand Down

0 comments on commit ed46830

Please sign in to comment.