remove some uses of visit_all_item_likes in typeck, symbol_mangling and passes crates
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
This commit is contained in:
parent
0baf85e8b6
commit
28aa2dd3b4
3 changed files with 49 additions and 6 deletions
|
@ -259,7 +259,22 @@ fn get_lang_items(tcx: TyCtxt<'_>, (): ()) -> LanguageItems {
|
|||
}
|
||||
|
||||
// Collect lang items in this crate.
|
||||
tcx.hir().visit_all_item_likes(&mut collector);
|
||||
let crate_items = tcx.hir_crate_items(());
|
||||
|
||||
for id in crate_items.items() {
|
||||
let item = tcx.hir().item(id);
|
||||
collector.visit_item(item);
|
||||
}
|
||||
|
||||
for id in crate_items.trait_items() {
|
||||
let item = tcx.hir().trait_item(id);
|
||||
collector.visit_trait_item(item);
|
||||
}
|
||||
|
||||
for id in crate_items.impl_items() {
|
||||
let item = tcx.hir().impl_item(id);
|
||||
collector.visit_impl_item(item);
|
||||
}
|
||||
|
||||
// Extract out the found lang items.
|
||||
let LanguageItemCollector { mut items, .. } = collector;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::{subst::InternalSubsts, Instance, TyCtxt};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
|
@ -23,7 +24,27 @@ pub fn report_symbol_names(tcx: TyCtxt<'_>) {
|
|||
|
||||
tcx.dep_graph.with_ignore(|| {
|
||||
let mut visitor = SymbolNamesTest { tcx };
|
||||
tcx.hir().visit_all_item_likes(&mut visitor);
|
||||
let crate_items = tcx.hir_crate_items(());
|
||||
|
||||
for id in crate_items.items() {
|
||||
let item = tcx.hir().item(id);
|
||||
visitor.visit_item(item);
|
||||
}
|
||||
|
||||
for id in crate_items.trait_items() {
|
||||
let item = tcx.hir().trait_item(id);
|
||||
visitor.visit_trait_item(item);
|
||||
}
|
||||
|
||||
for id in crate_items.impl_items() {
|
||||
let item = tcx.hir().impl_item(id);
|
||||
visitor.visit_impl_item(item);
|
||||
}
|
||||
|
||||
for id in crate_items.foreign_items() {
|
||||
let item = tcx.hir().foreign_item(id);
|
||||
visitor.visit_foreign_item(item);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,11 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
|
|||
}
|
||||
|
||||
let mut visitor = CheckVisitor { tcx, used_trait_imports };
|
||||
tcx.hir().visit_all_item_likes(&mut visitor);
|
||||
|
||||
for id in tcx.hir().items() {
|
||||
let item = tcx.hir().item(id);
|
||||
visitor.visit_item(item);
|
||||
}
|
||||
|
||||
unused_crates_lint(tcx);
|
||||
}
|
||||
|
@ -110,9 +114,12 @@ fn unused_crates_lint(tcx: TyCtxt<'_>) {
|
|||
|
||||
// Collect all the extern crates (in a reliable order).
|
||||
let mut crates_to_lint = vec![];
|
||||
tcx.hir().visit_all_item_likes(&mut CollectExternCrateVisitor {
|
||||
crates_to_lint: &mut crates_to_lint,
|
||||
});
|
||||
let mut visitor = CollectExternCrateVisitor { crates_to_lint: &mut crates_to_lint };
|
||||
|
||||
for id in tcx.hir().items() {
|
||||
let item = tcx.hir().item(id);
|
||||
visitor.visit_item(item);
|
||||
}
|
||||
|
||||
let extern_prelude = &tcx.resolutions(()).extern_prelude;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue