1
Fork 0

remove ItemLikeVisitor impls and add fast paths using DefKind

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
This commit is contained in:
Miguel Guarniz 2022-04-07 14:04:07 -04:00
parent 0d01ee9558
commit 3d6f4c85ad
2 changed files with 26 additions and 41 deletions

View file

@ -9,7 +9,6 @@ use rustc_hir as hir;
use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
use rustc_hir::def_id::{DefId, DefIdSet, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData};
use rustc_hir::ItemKind;
use rustc_session::config::TrimmedDefPaths;
use rustc_session::cstore::{ExternCrate, ExternCrateSource};
use rustc_span::symbol::{kw, Ident, Symbol};
@ -2683,8 +2682,12 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
// Iterate all local crate items no matter where they are defined.
let hir = tcx.hir();
for id in hir.items() {
if matches!(hir.def_kind(id.def_id), DefKind::Use) {
continue;
}
let item = hir.item(id);
if item.ident.name.as_str().is_empty() || matches!(item.kind, ItemKind::Use(_, _)) {
if item.ident.name.as_str().is_empty() {
continue;
}