Skip to content

Commit 373cc21

Browse files
committed
Change depth arg to at_root.
This will facilitate a subsequent refactoring.
1 parent 2ba4eb2 commit 373cc21

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

compiler/rustc_builtin_macros/src/test_harness.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,15 @@ impl<'a> Visitor<'a> for InnerItemLinter<'_> {
171171

172172
// Beware, this is duplicated in librustc_passes/entry.rs (with
173173
// `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 {
175175
match item.kind {
176176
ast::ItemKind::Fn(..) => {
177177
if attr::contains_name(&item.attrs, sym::start) {
178178
EntryPointType::Start
179179
} else if attr::contains_name(&item.attrs, sym::rustc_main) {
180180
EntryPointType::RustcMainAttr
181181
} else if item.ident.name == sym::main {
182-
if depth == 0 {
182+
if at_root {
183183
// This is a top-level function so can be 'main'
184184
EntryPointType::MainNamed
185185
} else {
@@ -210,7 +210,7 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> {
210210
// Remove any #[rustc_main] or #[start] from the AST so it doesn't
211211
// clash with the one we're going to add, but mark it as
212212
// #[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) {
214214
EntryPointType::MainNamed | EntryPointType::RustcMainAttr | EntryPointType::Start => {
215215
item.map(|ast::Item { id, ident, attrs, kind, vis, span, tokens }| {
216216
let allow_dead_code = attr::mk_attr_nested_word(

0 commit comments

Comments
 (0)