mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
avoid fetching HIR when handling Impl assoc items
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
This commit is contained in:
parent
f1c256d168
commit
959636d531
@ -511,18 +511,24 @@ fn check_item<'tcx>(
|
||||
}
|
||||
}
|
||||
DefKind::Impl => {
|
||||
let item = tcx.hir().item(id);
|
||||
if let hir::ItemKind::Impl(hir::Impl { ref of_trait, items, .. }) = item.kind {
|
||||
if of_trait.is_some() {
|
||||
worklist.push(item.def_id);
|
||||
}
|
||||
for impl_item_ref in *items {
|
||||
let impl_item = tcx.hir().impl_item(impl_item_ref.id);
|
||||
if of_trait.is_some()
|
||||
|| has_allow_dead_code_or_lang_attr(tcx, impl_item.hir_id())
|
||||
{
|
||||
worklist.push(impl_item_ref.id.def_id);
|
||||
}
|
||||
let of_trait = tcx.impl_trait_ref(id.def_id);
|
||||
|
||||
if of_trait.is_some() {
|
||||
worklist.push(id.def_id);
|
||||
}
|
||||
|
||||
// get DefIds from another query
|
||||
let local_def_ids = tcx
|
||||
.associated_item_def_ids(id.def_id)
|
||||
.iter()
|
||||
.filter_map(|def_id| def_id.as_local());
|
||||
|
||||
// And we access the Map here to get HirId from LocalDefId
|
||||
for id in local_def_ids {
|
||||
if of_trait.is_some()
|
||||
|| has_allow_dead_code_or_lang_attr(tcx, tcx.hir().local_def_id_to_hir_id(id))
|
||||
{
|
||||
worklist.push(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user