Rollup merge of #125214 - compiler-errors:gat-guide, r=lcnr
Only make GAT ambiguous in `match_projection_projections` considering shallow resolvability In #123537, I tweaked the hack from #93892 to use `resolve_vars_if_possible` instead of `shallow_resolve`. This considers more inference guidance ambiguous. This resulted in crater regressions in #125196. I've effectively reverted the change to the old behavior. That being said, I don't *like* this behavior, but I'd rather keep it for now since #123537 was not meant to make any behavioral changes. See the attached example. This also affects the new solver, for the record, which doesn't have any rules about not guiding inference from param-env candidates which may constrain GAT args as a side-effect. r? `@lcnr` or `@jackh726`
This commit is contained in:
commit
f08746a95d
2 changed files with 30 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue