about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2023-09-29 16:47:47 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2023-09-29 17:49:16 +1000
commit373cc2160a4bdf2c29b2a9620c5992dcc77eb4cb (patch)
treeb3672b7101f0399cbb1adf27363c57ccdaf8f5f9
parent2ba4eb2d49e774b5fbc2a06258ac7b0f60b92b7e (diff)
downloadrust-373cc2160a4bdf2c29b2a9620c5992dcc77eb4cb.tar.gz
rust-373cc2160a4bdf2c29b2a9620c5992dcc77eb4cb.zip
Change `depth` arg to `at_root`.
This will facilitate a subsequent refactoring.
-rw-r--r--compiler/rustc_builtin_macros/src/test_harness.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_builtin_macros/src/test_harness.rs b/compiler/rustc_builtin_macros/src/test_harness.rs
index 53ff089d7b4..026b4a2a6f6 100644
--- a/compiler/rustc_builtin_macros/src/test_harness.rs
+++ b/compiler/rustc_builtin_macros/src/test_harness.rs
@@ -171,7 +171,7 @@ impl<'a> Visitor<'a> for InnerItemLinter<'_> {
 
 // Beware, this is duplicated in librustc_passes/entry.rs (with
 // `rustc_hir::Item`), so make sure to keep them in sync.
-fn entry_point_type(item: &ast::Item, depth: usize) -> EntryPointType {
+fn entry_point_type(item: &ast::Item, at_root: bool) -> EntryPointType {
     match item.kind {
         ast::ItemKind::Fn(..) => {
             if attr::contains_name(&item.attrs, sym::start) {
@@ -179,7 +179,7 @@ fn entry_point_type(item: &ast::Item, depth: usize) -> EntryPointType {
             } else if attr::contains_name(&item.attrs, sym::rustc_main) {
                 EntryPointType::RustcMainAttr
             } else if item.ident.name == sym::main {
-                if depth == 0 {
+                if at_root {
                     // This is a top-level function so can be 'main'
                     EntryPointType::MainNamed
                 } else {
@@ -210,7 +210,7 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> {
         // Remove any #[rustc_main] or #[start] from the AST so it doesn't
         // clash with the one we're going to add, but mark it as
         // #[allow(dead_code)] to avoid printing warnings.
-        let item = match entry_point_type(&item, self.depth) {
+        let item = match entry_point_type(&item, self.depth == 0) {
             EntryPointType::MainNamed | EntryPointType::RustcMainAttr | EntryPointType::Start => {
                 item.map(|ast::Item { id, ident, attrs, kind, vis, span, tokens }| {
                     let allow_dead_code = attr::mk_attr_nested_word(