Files
codegraph/__tests__
Colby MchenryandClaude Opus 5.5 818e780336 fix(rust): a trait's associated type named <T as Trait>::X or bound as Trait<X = …> links only to what it names (#2712)
A trait's associated type is named in two more ways than `Self::X`, and
neither names a module item:
- Through a qualified self, `<T as Trait>::X`. isRustNameInScope took any
  associated item of the name for it. axum's `<L as Listener>::Io`, with
  `L` a generic, went to `ReadyListener`'s `type Io`. A trait's own
  `fn call(…) -> <Self as HandlerCallWithExtractors<T, S>>::Future;`
  went to an impl's `type Future` further down the file.
- As a binding in the trait's arguments, `Iterator<Item = &str>` or
  `Readable<Storage = UnsyncStorage>`. The name was matched like a bare
  type. axum's `impl Iterator<Item = &str>` went to a same-file
  `enum Item`, and dioxus's `Storage = …` bindings to the `Storage` trait.

Fix, in isRustNameInScope:
- isRustAssocBinding: a name followed by `=` or `:` inside an unclosed
  `<` on its line is a binding or bound, and links nothing. The trait's
  own associated type is no node.
- rustQualifiedSelf reads `<T as Trait>::X` (and `<T>::X`) as its self
  type and trait, each as the last segment of its path:
  - `Self` means `Self::X`: the enclosing impl's own item, nothing in a
    trait's body;
  - a generic means no impl's;
  - a type means its impl of that trait (the candidate's
    `Owner::Name` must match, and its impl header's trait too).

Tests: rust-assoc-qualified-self.test.ts, 3 tests, on both engines; all
3 fail before the fix, and switching off either rule fails its tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 18:11:39 +00:00
..