fix: ensure implied bounds from associated types are considered in au… · rust-lang/rust@f2c3ef7 (original) (raw)

Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
3 3 use hir::{
4 4 db::HirDatabase, AsAssocItem, AssocItem, AssocItemContainer, Crate, HasCrate, ImportPathConfig,
5 5 ItemInNs, ModPath, Module, ModuleDef, Name, PathResolution, PrefixKind, ScopeDef, Semantics,
6 -SemanticsScope, Trait, Type,
6 +SemanticsScope, Trait, TyFingerprint, Type,
7 7 };
8 8 use itertools::{EitherOrBoth, Itertools};
9 9 use rustc_hash::{FxHashMap, FxHashSet};
@@ -545,6 +545,15 @@ fn trait_applicable_items(
545 545 let Some(receiver) = trait_candidate.receiver_ty.fingerprint_for_trait_impl() else {
546 546 return false;
547 547 };
548 +
549 +// in order to handle implied bounds through an associated type, keep any
550 +// method receiver that matches `TyFingerprint::Unnameable`. this receiver
551 +// won't be in `TraitImpls` anyways, as `TraitImpls` only contains actual
552 +// implementations.
553 +if matches!(receiver, TyFingerprint::Unnameable) {
554 +return true;
555 +}
556 +
548 557 let definitions_exist_in_trait_crate = db
549 558 .trait_impls_in_crate(defining_crate_for_trait.into())
550 559 .has_impls_for_trait_and_self_ty(candidate_trait_id, receiver);