Open
Description
During the work on #40668, there was some discussion about refactoring the ty::AssociatedItem
and hir::{Impl,Trait}ItemRef
data structures. The precise plan is a bit unclear, so I'm opening this issue to try and discuss and lay it out.
Observations:
- Although
ty::AssociatedItem
lives inty
, it has no real dependencies and is based entirely on the HIR, so it would better live in HIR.- The existing
ImplItemRef
andTraitItemRef
are basically specialized variants ofAssociatedItem
, though they add aSpan
and use local-ids (ImplItemId
) rather than aDefId
.
- The existing
- There is a need for a query that given a
DefId
gives you back theAssociatedItem
(including across crates). The local-crate portion of this query seems like it could live inhir::map
quite nicely. - Some of this setup is carefully crafted to avoid incorrect incremental dependencies and can change as we progress on the proposed red/green changes (in particular, the current query goes to some lengths to avoid reading from
Hir(X)
when computingAssociatedItem(X)
, instead reading from the containing impl/trait; this is because we don't want to require everything that needed even basic information aboutX
to have to change whenX
changes).