Skip to content

Commit fb73ae2

Browse files
committed
remove ItemLikeVisitor impl for EntryContext
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
1 parent dab0e75 commit fb73ae2

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

compiler/rustc_passes/src/entry.rs

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use rustc_ast::entry::EntryPointType;
22
use rustc_errors::struct_span_err;
33
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID, LOCAL_CRATE};
4-
use rustc_hir::itemlikevisit::ItemLikeVisitor;
5-
use rustc_hir::{ForeignItem, ImplItem, Item, ItemKind, Node, TraitItem, CRATE_HIR_ID};
4+
use rustc_hir::{Item, ItemKind, Node, CRATE_HIR_ID};
65
use rustc_middle::ty::query::Providers;
76
use rustc_middle::ty::{DefIdTree, TyCtxt};
87
use rustc_session::config::{CrateType, EntryFnType};
@@ -25,25 +24,6 @@ struct EntryContext<'tcx> {
2524
non_main_fns: Vec<Span>,
2625
}
2726

28-
impl<'tcx> ItemLikeVisitor<'tcx> for EntryContext<'tcx> {
29-
fn visit_item(&mut self, item: &'tcx Item<'tcx>) {
30-
let at_root = self.tcx.opt_local_parent(item.def_id) == Some(CRATE_DEF_ID);
31-
find_item(item, self, at_root);
32-
}
33-
34-
fn visit_trait_item(&mut self, _trait_item: &'tcx TraitItem<'tcx>) {
35-
// Entry fn is never a trait item.
36-
}
37-
38-
fn visit_impl_item(&mut self, _impl_item: &'tcx ImplItem<'tcx>) {
39-
// Entry fn is never a trait item.
40-
}
41-
42-
fn visit_foreign_item(&mut self, _: &'tcx ForeignItem<'tcx>) {
43-
// Entry fn is never a foreign item.
44-
}
45-
}
46-
4727
fn entry_fn(tcx: TyCtxt<'_>, (): ()) -> Option<(DefId, EntryFnType)> {
4828
let any_exe = tcx.sess.crate_types().iter().any(|ty| *ty == CrateType::Executable);
4929
if !any_exe {
@@ -59,7 +39,10 @@ fn entry_fn(tcx: TyCtxt<'_>, (): ()) -> Option<(DefId, EntryFnType)> {
5939
let mut ctxt =
6040
EntryContext { tcx, attr_main_fn: None, start_fn: None, non_main_fns: Vec::new() };
6141

62-
tcx.hir().visit_all_item_likes(&mut ctxt);
42+
for id in tcx.hir().items() {
43+
let item = tcx.hir().item(id);
44+
find_item(item, &mut ctxt);
45+
}
6346

6447
configure_main(tcx, &ctxt)
6548
}
@@ -89,7 +72,9 @@ fn throw_attr_err(sess: &Session, span: Span, attr: &str) {
8972
.emit();
9073
}
9174

92-
fn find_item(item: &Item<'_>, ctxt: &mut EntryContext<'_>, at_root: bool) {
75+
fn find_item(item: &Item<'_>, ctxt: &mut EntryContext<'_>) {
76+
let at_root = ctxt.tcx.opt_local_parent(item.def_id) == Some(CRATE_DEF_ID);
77+
9378
match entry_point_type(ctxt, item, at_root) {
9479
EntryPointType::None => (),
9580
_ if !matches!(item.kind, ItemKind::Fn(..)) => {

0 commit comments

Comments
 (0)