diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 6cdfa6ca45a7d..cb38a16db35f8 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -105,7 +105,7 @@ pub trait MutVisitor: Sized { } fn visit_foreign_item(&mut self, ni: &mut P) { - walk_item(self, ni, ()); + walk_item(self, ni); } fn flat_map_foreign_item(&mut self, ni: P) -> SmallVec<[P; 1]> { @@ -113,7 +113,7 @@ pub trait MutVisitor: Sized { } fn visit_item(&mut self, i: &mut P) { - walk_item(self, i, ()); + walk_item(self, i); } fn flat_map_item(&mut self, i: P) -> SmallVec<[P; 1]> { @@ -133,7 +133,7 @@ pub trait MutVisitor: Sized { } fn visit_assoc_item(&mut self, i: &mut P, ctxt: AssocCtxt) { - walk_item(self, i, ctxt) + walk_assoc_item(self, i, ctxt) } fn flat_map_assoc_item( @@ -1395,7 +1395,15 @@ pub fn walk_crate(vis: &mut T, krate: &mut Crate) { vis.visit_span(inject_use_span); } -pub fn walk_item( +pub fn walk_item(visitor: &mut impl MutVisitor, item: &mut P>>) { + walk_item_ctxt(visitor, item, ()) +} + +pub fn walk_assoc_item(visitor: &mut impl MutVisitor, item: &mut P, ctxt: AssocCtxt) { + walk_item_ctxt(visitor, item, ctxt) +} + +fn walk_item_ctxt( visitor: &mut impl MutVisitor, item: &mut P>, ctxt: K::Ctxt, diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 88d4edd87c8e7..fafef4169f49b 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -143,10 +143,10 @@ pub trait Visitor<'ast>: Sized { Self::Result::output() } fn visit_foreign_item(&mut self, i: &'ast ForeignItem) -> Self::Result { - walk_item(self, i, ()) + walk_item(self, i) } fn visit_item(&mut self, i: &'ast Item) -> Self::Result { - walk_item(self, i, ()) + walk_item(self, i) } fn visit_local(&mut self, l: &'ast Local) -> Self::Result { walk_local(self, l) @@ -196,7 +196,7 @@ pub trait Visitor<'ast>: Sized { walk_fn(self, fk) } fn visit_assoc_item(&mut self, i: &'ast AssocItem, ctxt: AssocCtxt) -> Self::Result { - walk_item(self, i, ctxt) + walk_assoc_item(self, i, ctxt) } fn visit_trait_ref(&mut self, t: &'ast TraitRef) -> Self::Result { walk_trait_ref(self, t) @@ -918,7 +918,22 @@ impl WalkItemKind for AssocItemKind { } } -pub fn walk_item<'a, V: Visitor<'a>, K: WalkItemKind>( +pub fn walk_item<'a, V: Visitor<'a>>( + visitor: &mut V, + item: &'a Item>, +) -> V::Result { + walk_item_ctxt(visitor, item, ()) +} + +pub fn walk_assoc_item<'a, V: Visitor<'a>>( + visitor: &mut V, + item: &'a AssocItem, + ctxt: AssocCtxt, +) -> V::Result { + walk_item_ctxt(visitor, item, ctxt) +} + +fn walk_item_ctxt<'a, V: Visitor<'a>, K: WalkItemKind>( visitor: &mut V, item: &'a Item, ctxt: K::Ctxt, diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index cbab39423bf4a..d53280751fca2 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -379,21 +379,21 @@ fn index_crate<'a>( fn visit_item(&mut self, item: &'a ast::Item) { let def_id = self.node_id_to_def_id[&item.id]; *self.index.ensure_contains_elem(def_id, || AstOwner::NonOwner) = AstOwner::Item(item); - visit::walk_item(self, item, ()) + visit::walk_item(self, item) } fn visit_assoc_item(&mut self, item: &'a ast::AssocItem, ctxt: visit::AssocCtxt) { let def_id = self.node_id_to_def_id[&item.id]; *self.index.ensure_contains_elem(def_id, || AstOwner::NonOwner) = AstOwner::AssocItem(item, ctxt); - visit::walk_item(self, item, ctxt); + visit::walk_assoc_item(self, item, ctxt); } fn visit_foreign_item(&mut self, item: &'a ast::ForeignItem) { let def_id = self.node_id_to_def_id[&item.id]; *self.index.ensure_contains_elem(def_id, || AstOwner::NonOwner) = AstOwner::ForeignItem(item); - visit::walk_item(self, item, ()); + visit::walk_item(self, item); } } } diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 331610d847ad2..07a6f4e5ee73c 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -977,7 +977,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { if abi.is_none() { this.maybe_lint_missing_abi(*extern_span, item.id); } - visit::walk_item(this, item, ()); + visit::walk_item(this, item); this.extern_mod = old_item; }); return; // Avoid visiting again. @@ -1112,7 +1112,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { _ => {} } - visit::walk_item(self, item, ()); + visit::walk_item(self, item); } fn visit_foreign_item(&mut self, fi: &'a ForeignItem) { @@ -1145,7 +1145,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { ForeignItemKind::MacCall(..) => {} } - visit::walk_item(self, fi, ()) + visit::walk_item(self, fi) } // Mirrors `visit::walk_generic_args`, but tracks relevant state. @@ -1491,10 +1491,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> { None => TildeConstReason::InherentAssocTy { span: item.span }, }); self.with_tilde_const(disallowed, |this| { - this.with_in_trait_impl(None, |this| visit::walk_item(this, item, ctxt)) + this.with_in_trait_impl(None, |this| visit::walk_assoc_item(this, item, ctxt)) }) } - _ => self.with_in_trait_impl(None, |this| visit::walk_item(this, item, ctxt)), + _ => self.with_in_trait_impl(None, |this| visit::walk_assoc_item(this, item, ctxt)), } } } diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 4e727b8637258..be6f2c152a4d2 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -299,7 +299,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { _ => {} } - visit::walk_item(self, i, ()); + visit::walk_item(self, i); } fn visit_foreign_item(&mut self, i: &'a ast::ForeignItem) { @@ -322,7 +322,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { ast::ForeignItemKind::MacCall(..) => {} } - visit::walk_item(self, i, ()) + visit::walk_item(self, i) } fn visit_ty(&mut self, ty: &'a ast::Ty) { @@ -477,7 +477,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { "specialization is unstable" ); } - visit::walk_item(self, i, ctxt) + visit::walk_assoc_item(self, i, ctxt) } } diff --git a/compiler/rustc_ast_passes/src/node_count.rs b/compiler/rustc_ast_passes/src/node_count.rs index 8df34f25345dd..9e7204df8adf1 100644 --- a/compiler/rustc_ast_passes/src/node_count.rs +++ b/compiler/rustc_ast_passes/src/node_count.rs @@ -21,11 +21,11 @@ impl<'ast> Visitor<'ast> for NodeCounter { } fn visit_foreign_item(&mut self, i: &ForeignItem) { self.count += 1; - walk_item(self, i, ()) + walk_item(self, i) } fn visit_item(&mut self, i: &Item) { self.count += 1; - walk_item(self, i, ()) + walk_item(self, i) } fn visit_local(&mut self, l: &Local) { self.count += 1; @@ -69,7 +69,7 @@ impl<'ast> Visitor<'ast> for NodeCounter { } fn visit_assoc_item(&mut self, ti: &AssocItem, ctxt: AssocCtxt) { self.count += 1; - walk_item(self, ti, ctxt); + walk_assoc_item(self, ti, ctxt); } fn visit_trait_ref(&mut self, t: &TraitRef) { self.count += 1; diff --git a/compiler/rustc_builtin_macros/src/proc_macro_harness.rs b/compiler/rustc_builtin_macros/src/proc_macro_harness.rs index d14731c7ae2bd..707c36d5046a9 100644 --- a/compiler/rustc_builtin_macros/src/proc_macro_harness.rs +++ b/compiler/rustc_builtin_macros/src/proc_macro_harness.rs @@ -210,7 +210,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> { let Some(attr) = found_attr else { self.check_not_pub_in_root(&item.vis, self.source_map.guess_head_span(item.span)); let prev_in_root = mem::replace(&mut self.in_root, false); - visit::walk_item(self, item, ()); + visit::walk_item(self, item); self.in_root = prev_in_root; return; }; @@ -248,7 +248,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> { }; let prev_in_root = mem::replace(&mut self.in_root, false); - visit::walk_item(self, item, ()); + visit::walk_item(self, item); self.in_root = prev_in_root; } } diff --git a/compiler/rustc_builtin_macros/src/test_harness.rs b/compiler/rustc_builtin_macros/src/test_harness.rs index cd1ea74c1c17b..b2048c534a48a 100644 --- a/compiler/rustc_builtin_macros/src/test_harness.rs +++ b/compiler/rustc_builtin_macros/src/test_harness.rs @@ -157,7 +157,7 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> { self.add_test_cases(item.id, span, prev_tests); } else { // But in those cases, we emit a lint to warn the user of these missing tests. - walk_item(&mut InnerItemLinter { sess: self.cx.ext_cx.sess }, &item, ()); + walk_item(&mut InnerItemLinter { sess: self.cx.ext_cx.sess }, &item); } } } @@ -200,7 +200,7 @@ struct EntryPointCleaner<'a> { impl<'a> MutVisitor for EntryPointCleaner<'a> { fn visit_item(&mut self, item: &mut P) { self.depth += 1; - ast::mut_visit::walk_item(self, item, ()); + ast::mut_visit::walk_item(self, item); self.depth -= 1; // Remove any #[rustc_main] or #[start] from the AST so it doesn't diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index 0f56611c2f2a4..19c2d466f7ca6 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -902,7 +902,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { _ => {} } - visit::walk_item(self, item, ()); + visit::walk_item(self, item); } } diff --git a/compiler/rustc_lint/src/early.rs b/compiler/rustc_lint/src/early.rs index 00d02e0ea3f24..4f3184f1d7cff 100644 --- a/compiler/rustc_lint/src/early.rs +++ b/compiler/rustc_lint/src/early.rs @@ -82,14 +82,14 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T> fn visit_item(&mut self, it: &'a ast::Item) { self.with_lint_attrs(it.id, &it.attrs, |cx| { lint_callback!(cx, check_item, it); - ast_visit::walk_item(cx, it, ()); + ast_visit::walk_item(cx, it); lint_callback!(cx, check_item_post, it); }) } fn visit_foreign_item(&mut self, it: &'a ast::ForeignItem) { self.with_lint_attrs(it.id, &it.attrs, |cx| { - ast_visit::walk_item(cx, it, ()); + ast_visit::walk_item(cx, it); }) } @@ -239,7 +239,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T> lint_callback!(cx, check_impl_item, item); } } - ast_visit::walk_item(cx, item, ctxt); + ast_visit::walk_assoc_item(cx, item, ctxt); }); } diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index e65f5460d9e9b..ca16a66763ac9 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -1105,7 +1105,7 @@ fn global_allocator_spans(krate: &ast::Crate) -> Vec { { self.spans.push(item.span); } - visit::walk_item(self, item, ()) + visit::walk_item(self, item) } } @@ -1127,7 +1127,7 @@ fn alloc_error_handler_spans(krate: &ast::Crate) -> Vec { { self.spans.push(item.span); } - visit::walk_item(self, item, ()) + visit::walk_item(self, item) } } diff --git a/compiler/rustc_parse/src/parser/tests.rs b/compiler/rustc_parse/src/parser/tests.rs index 5955027f8cd02..decaecd2682ce 100644 --- a/compiler/rustc_parse/src/parser/tests.rs +++ b/compiler/rustc_parse/src/parser/tests.rs @@ -2438,7 +2438,7 @@ fn get_spans_of_pat_idents(src: &str) -> Vec { } } let mut v = PatIdentVisitor { spans: Vec::new() }; - visit::walk_item(&mut v, &item, ()); + visit::walk_item(&mut v, &item); return v.spans; } diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs index 2b961028614bf..55fdbac8ad67a 100644 --- a/compiler/rustc_passes/src/hir_stats.rs +++ b/compiler/rustc_passes/src/hir_stats.rs @@ -477,7 +477,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> { record_variants!((self, i, i.kind, None, ast, ForeignItem, ForeignItemKind), [ Static, Fn, TyAlias, MacCall ]); - ast_visit::walk_item(self, i, ()) + ast_visit::walk_item(self, i) } fn visit_item(&mut self, i: &'v ast::Item) { @@ -502,7 +502,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> { Delegation, DelegationMac ]); - ast_visit::walk_item(self, i, ()) + ast_visit::walk_item(self, i) } fn visit_local(&mut self, l: &'v ast::Local) { @@ -626,7 +626,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> { Delegation, DelegationMac ]); - ast_visit::walk_item(self, i, ctxt); + ast_visit::walk_assoc_item(self, i, ctxt); } fn visit_param_bound(&mut self, b: &'v ast::GenericBound, _ctxt: BoundKind) { diff --git a/compiler/rustc_passes/src/lang_items.rs b/compiler/rustc_passes/src/lang_items.rs index 7ce0f521f0616..19f00aa3c1b3b 100644 --- a/compiler/rustc_passes/src/lang_items.rs +++ b/compiler/rustc_passes/src/lang_items.rs @@ -299,7 +299,7 @@ impl<'ast, 'tcx> visit::Visitor<'ast> for LanguageItemCollector<'ast, 'tcx> { ); let parent_item = self.parent_item.replace(i); - visit::walk_item(self, i, ()); + visit::walk_item(self, i); self.parent_item = parent_item; } @@ -355,7 +355,7 @@ impl<'ast, 'tcx> visit::Visitor<'ast> for LanguageItemCollector<'ast, 'tcx> { generics, ); - visit::walk_item(self, i, ctxt); + visit::walk_assoc_item(self, i, ctxt); } } diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 89da21e43bb27..293cee500bbd8 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -1311,7 +1311,7 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for BuildReducedGraphVisitor<'a, 'ra, 'tcx> { self.parent_scope.macro_rules = match item.kind { ItemKind::MacroDef(..) => { let macro_rules_scope = self.define_macro(item); - visit::walk_item(self, item, ()); + visit::walk_item(self, item); macro_rules_scope } ItemKind::MacCall(..) => self.visit_invoc_in_module(item.id), @@ -1327,7 +1327,7 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for BuildReducedGraphVisitor<'a, 'ra, 'tcx> { item.kind.walk(item.span, item.id, &item.ident, &item.vis, (), self); visit::walk_list!(self, visit_attribute, &item.attrs); } - _ => visit::walk_item(self, item, ()), + _ => visit::walk_item(self, item), } match item.kind { ItemKind::Mod(..) if self.contains_macro_use(&item.attrs) => { @@ -1355,7 +1355,7 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for BuildReducedGraphVisitor<'a, 'ra, 'tcx> { } self.build_reduced_graph_for_foreign_item(foreign_item); - visit::walk_item(self, foreign_item, ()); + visit::walk_item(self, foreign_item); } fn visit_block(&mut self, block: &'a Block) { @@ -1420,7 +1420,7 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for BuildReducedGraphVisitor<'a, 'ra, 'tcx> { self.r.impl_binding_keys.entry(impl_def_id).or_default().insert(key); } - visit::walk_item(self, item, ctxt); + visit::walk_assoc_item(self, item, ctxt); } fn visit_attribute(&mut self, attr: &'a ast::Attribute) { diff --git a/compiler/rustc_resolve/src/check_unused.rs b/compiler/rustc_resolve/src/check_unused.rs index 4266c298bb1a7..e36055e85755e 100644 --- a/compiler/rustc_resolve/src/check_unused.rs +++ b/compiler/rustc_resolve/src/check_unused.rs @@ -235,7 +235,7 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for UnusedImportCheckVisitor<'a, 'ra, 'tcx> { } self.item_span = item.span_with_attributes(); - visit::walk_item(self, item, ()); + visit::walk_item(self, item); } fn visit_use_tree(&mut self, use_tree: &'a ast::UseTree, id: ast::NodeId, nested: bool) { diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index 385808beb5653..bf27b767a4972 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -199,7 +199,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { DefKind::Macro(macro_kind) } ItemKind::GlobalAsm(..) => DefKind::GlobalAsm, - ItemKind::Use(..) => return visit::walk_item(self, i, ()), + ItemKind::Use(..) => return visit::walk_item(self, i), ItemKind::MacCall(..) | ItemKind::DelegationMac(..) => { return self.visit_macro_invoc(i.id); } @@ -226,7 +226,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { } _ => {} } - visit::walk_item(this, i, ()); + visit::walk_item(this, i); }) }); } @@ -301,7 +301,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { let def = self.create_def(fi.id, fi.ident.name, def_kind, fi.span); - self.with_parent(def, |this| visit::walk_item(this, fi, ())); + self.with_parent(def, |this| visit::walk_item(this, fi)); } fn visit_variant(&mut self, v: &'a Variant) { @@ -365,7 +365,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { }; let def = self.create_def(i.id, i.ident.name, def_kind, i.span); - self.with_parent(def, |this| visit::walk_item(this, i, ctxt)); + self.with_parent(def, |this| visit::walk_assoc_item(this, i, ctxt)); } fn visit_pat(&mut self, pat: &'a Pat) { diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 24d7ef6d1566d..5437ca65935f8 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -3055,7 +3055,7 @@ impl<'tcx> visit::Visitor<'tcx> for UsePlacementFinder { return; } } else { - visit::walk_item(self, item, ()); + visit::walk_item(self, item); } } } diff --git a/compiler/rustc_resolve/src/effective_visibilities.rs b/compiler/rustc_resolve/src/effective_visibilities.rs index 1bd6a93f9ac9b..e279d14704e05 100644 --- a/compiler/rustc_resolve/src/effective_visibilities.rs +++ b/compiler/rustc_resolve/src/effective_visibilities.rs @@ -247,7 +247,7 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for EffectiveVisibilitiesVisitor<'a, 'ra, 'tcx> let prev_private_vis = mem::replace(&mut self.current_private_vis, Visibility::Restricted(def_id)); self.set_bindings_effective_visibilities(def_id); - visit::walk_item(self, item, ()); + visit::walk_item(self, item); self.current_private_vis = prev_private_vis; } diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index d557df65476c8..f4a85c358e38c 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -932,7 +932,7 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r kind: LifetimeBinderKind::Item, span: generics.span, }, - |this| visit::walk_item(this, foreign_item, ()), + |this| visit::walk_item(this, foreign_item), ); } ForeignItemKind::Fn(box Fn { ref generics, .. }) => { @@ -944,11 +944,11 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r kind: LifetimeBinderKind::Function, span: generics.span, }, - |this| visit::walk_item(this, foreign_item, ()), + |this| visit::walk_item(this, foreign_item), ); } ForeignItemKind::Static(..) => { - self.with_static_rib(def_kind, |this| visit::walk_item(this, foreign_item, ())) + self.with_static_rib(def_kind, |this| visit::walk_item(this, foreign_item)) } ForeignItemKind::MacCall(..) => { panic!("unexpanded macro in resolve!") @@ -2478,7 +2478,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { is_trait_impl: false, }, |this| { - visit::walk_item(this, item, ()); + visit::walk_item(this, item); }, ); }, @@ -2547,7 +2547,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { kind: LifetimeBinderKind::Item, span: generics.span, }, - |this| visit::walk_item(this, item, ()), + |this| visit::walk_item(this, item), ); } @@ -2560,7 +2560,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { kind: LifetimeBinderKind::Function, span: generics.span, }, - |this| visit::walk_item(this, item, ()), + |this| visit::walk_item(this, item), ); } @@ -2636,7 +2636,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { this.resolve_doc_links(&item.attrs, MaybeExported::Ok(item.id)); } let old_macro_rules = this.parent_scope.macro_rules; - visit::walk_item(this, item, ()); + visit::walk_item(this, item); // Maintain macro_rules scopes in the same way as during early resolution // for diagnostics and doc links. if item.attrs.iter().all(|attr| { @@ -2721,7 +2721,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } ItemKind::ForeignMod(_) | ItemKind::GlobalAsm(_) => { - visit::walk_item(self, item, ()); + visit::walk_item(self, item); } ItemKind::Delegation(ref delegation) => { @@ -2991,7 +2991,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { &generics.params, RibKind::AssocItem, LifetimeRibKind::Generics { binder: item.id, span: generics.span, kind }, - |this| visit::walk_item(this, item, AssocCtxt::Trait), + |this| visit::walk_assoc_item(this, item, AssocCtxt::Trait), ); }; @@ -3266,7 +3266,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |i, s, c| MethodNotMemberOfTrait(i, s, c), ); - visit::walk_item(this, item, AssocCtxt::Impl) + visit::walk_assoc_item(this, item, AssocCtxt::Impl) }, ); } @@ -3296,7 +3296,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |i, s, c| TypeNotMemberOfTrait(i, s, c), ); - visit::walk_item(this, item, AssocCtxt::Impl) + visit::walk_assoc_item(this, item, AssocCtxt::Impl) }); }, ); @@ -4991,14 +4991,14 @@ impl<'ast> Visitor<'ast> for ItemInfoCollector<'_, '_, '_> { // but for delegation items we are never actually retrieving that count in practice. } } - visit::walk_item(self, item, ()) + visit::walk_item(self, item) } fn visit_assoc_item(&mut self, item: &'ast AssocItem, ctxt: AssocCtxt) { if let AssocItemKind::Fn(box Fn { ref sig, .. }) = &item.kind { self.collect_fn_info(sig, item.id); } - visit::walk_item(self, item, ctxt); + visit::walk_assoc_item(self, item, ctxt); } } diff --git a/src/tools/clippy/clippy_lints/src/excessive_nesting.rs b/src/tools/clippy/clippy_lints/src/excessive_nesting.rs index 759c6c2b44789..ffc76366983aa 100644 --- a/src/tools/clippy/clippy_lints/src/excessive_nesting.rs +++ b/src/tools/clippy/clippy_lints/src/excessive_nesting.rs @@ -167,7 +167,7 @@ impl Visitor<'_> for NestingVisitor<'_, '_> { self.nest_level += 1; if !self.check_indent(item.span, item.id) { - walk_item(self, item, ()) + walk_item(self, item); } self.nest_level -= 1; @@ -180,9 +180,8 @@ impl Visitor<'_> for NestingVisitor<'_, '_> { nest_level: 0, }, item, - (), ), - _ => walk_item(self, item, ()), + _ => walk_item(self, item), } } }