Only store a LocalDefId in hir::ImplItem.

This commit is contained in:
Camille GILLOT 2021-01-30 23:25:03 +01:00
parent a871a0f111
commit 786a80e9ea
56 changed files with 163 additions and 165 deletions

View file

@ -105,7 +105,7 @@ fn associated_item_from_impl_item_ref(
parent_def_id: LocalDefId,
impl_item_ref: &hir::ImplItemRef<'_>,
) -> ty::AssocItem {
let def_id = tcx.hir().local_def_id(impl_item_ref.id.hir_id);
let def_id = impl_item_ref.id.def_id;
let (kind, has_self) = match impl_item_ref.kind {
hir::AssocItemKind::Const => (ty::AssocKind::Const, false),
hir::AssocItemKind::Fn { has_self } => (ty::AssocKind::Fn, has_self),
@ -130,7 +130,9 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
let parent_item = tcx.hir().expect_item(parent_id);
match parent_item.kind {
hir::ItemKind::Impl(ref impl_) => {
if let Some(impl_item_ref) = impl_.items.iter().find(|i| i.id.hir_id == id) {
if let Some(impl_item_ref) =
impl_.items.iter().find(|i| i.id.def_id.to_def_id() == def_id)
{
let assoc_item =
associated_item_from_impl_item_ref(tcx, parent_def_id, impl_item_ref);
debug_assert_eq!(assoc_item.def_id, def_id);
@ -201,11 +203,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
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_
.items
.iter()
.map(|impl_item_ref| impl_item_ref.id)
.map(|id| tcx.hir().local_def_id(id.hir_id).to_def_id()),
impl_.items.iter().map(|impl_item_ref| impl_item_ref.id.def_id.to_def_id()),
),
hir::ItemKind::TraitAlias(..) => &[],
_ => span_bug!(item.span, "associated_item_def_ids: not impl or trait"),