1
Fork 0

Rollup merge of #111695 - fmease:dont-lump-together-alias-tys, r=compiler-errors

Exclude inherent projections from some alias type `match`es

Updating (hopefully) all remaining `match`es which I overlooked to update when adding `AliasKind::Inherent` in #109410.

Fixes #111399.
Sadly the regression test is a clippy test instead of a rustc one as I don't know of another way to test that a trait bound like `Ty::InhProj: Trait` doesn't cause a crash without reaching a cycle error first (this is getting old ^^').

`@rustbot` label F-inherent_associated_types
r? `@compiler-errors`
This commit is contained in:
Dylan DPC 2023-05-18 17:37:09 +05:30 committed by GitHub
commit d2823a1bbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 5 deletions

View file

@ -1543,7 +1543,10 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>(
// Check whether the self-type is itself a projection.
// If so, extract what we know from the trait and try to come up with a good answer.
let bounds = match *obligation.predicate.self_ty().kind() {
ty::Alias(_, ref data) => tcx.item_bounds(data.def_id).subst(tcx, data.substs),
// Excluding IATs here as they don't have meaningful item bounds.
ty::Alias(ty::Projection | ty::Opaque, ref data) => {
tcx.item_bounds(data.def_id).subst(tcx, data.substs)
}
ty::Infer(ty::TyVar(_)) => {
// If the self-type is an inference variable, then it MAY wind up
// being a projected type, so induce an ambiguity.