Only store a LocalDefId in hir::TraitItem.
This commit is contained in:
@@ -82,7 +82,7 @@ fn associated_item_from_trait_item_ref(
|
||||
parent_def_id: LocalDefId,
|
||||
trait_item_ref: &hir::TraitItemRef,
|
||||
) -> ty::AssocItem {
|
||||
let def_id = tcx.hir().local_def_id(trait_item_ref.id.hir_id);
|
||||
let def_id = trait_item_ref.id.def_id;
|
||||
let (kind, has_self) = match trait_item_ref.kind {
|
||||
hir::AssocItemKind::Const => (ty::AssocKind::Const, false),
|
||||
hir::AssocItemKind::Fn { has_self } => (ty::AssocKind::Fn, has_self),
|
||||
@@ -139,7 +139,9 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
|
||||
}
|
||||
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
if let Some(trait_item_ref) = trait_item_refs.iter().find(|i| i.id.hir_id == id) {
|
||||
if let Some(trait_item_ref) =
|
||||
trait_item_refs.iter().find(|i| i.id.def_id.to_def_id() == def_id)
|
||||
{
|
||||
let assoc_item =
|
||||
associated_item_from_trait_item_ref(tcx, parent_def_id, trait_item_ref);
|
||||
debug_assert_eq!(assoc_item.def_id, def_id);
|
||||
@@ -196,10 +198,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
|
||||
let item = tcx.hir().expect_item(id);
|
||||
match item.kind {
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => tcx.arena.alloc_from_iter(
|
||||
trait_item_refs
|
||||
.iter()
|
||||
.map(|trait_item_ref| trait_item_ref.id)
|
||||
.map(|id| tcx.hir().local_def_id(id.hir_id).to_def_id()),
|
||||
trait_item_refs.iter().map(|trait_item_ref| trait_item_ref.id.def_id.to_def_id()),
|
||||
),
|
||||
hir::ItemKind::Impl(ref impl_) => tcx.arena.alloc_from_iter(
|
||||
impl_
|
||||
|
||||
Reference in New Issue
Block a user