@@ -171,15 +171,15 @@ impl<'a> Visitor<'a> for InnerItemLinter<'_> {
171
171
172
172
// Beware, this is duplicated in librustc_passes/entry.rs (with
173
173
// `rustc_hir::Item`), so make sure to keep them in sync.
174
- fn entry_point_type ( item : & ast:: Item , depth : usize ) -> EntryPointType {
174
+ fn entry_point_type ( item : & ast:: Item , at_root : bool ) -> EntryPointType {
175
175
match item. kind {
176
176
ast:: ItemKind :: Fn ( ..) => {
177
177
if attr:: contains_name ( & item. attrs , sym:: start) {
178
178
EntryPointType :: Start
179
179
} else if attr:: contains_name ( & item. attrs , sym:: rustc_main) {
180
180
EntryPointType :: RustcMainAttr
181
181
} else if item. ident . name == sym:: main {
182
- if depth == 0 {
182
+ if at_root {
183
183
// This is a top-level function so can be 'main'
184
184
EntryPointType :: MainNamed
185
185
} else {
@@ -210,7 +210,7 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> {
210
210
// Remove any #[rustc_main] or #[start] from the AST so it doesn't
211
211
// clash with the one we're going to add, but mark it as
212
212
// #[allow(dead_code)] to avoid printing warnings.
213
- let item = match entry_point_type ( & item, self . depth ) {
213
+ let item = match entry_point_type ( & item, self . depth == 0 ) {
214
214
EntryPointType :: MainNamed | EntryPointType :: RustcMainAttr | EntryPointType :: Start => {
215
215
item. map ( |ast:: Item { id, ident, attrs, kind, vis, span, tokens } | {
216
216
let allow_dead_code = attr:: mk_attr_nested_word (
0 commit comments