From 8c5303898e43b7062bd66145bace076ce1a0b690 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 10 Aug 2022 11:22:01 +1000 Subject: [PATCH 1/4] Simplify `rustc_hir::intravisit::Visitor::visit_variant_data`. It has four arguments that are never used. This avoids lots of argument passing in functions that feed into `visit_variant_data`. --- compiler/rustc_ast_lowering/src/index.rs | 4 +- compiler/rustc_hir/src/intravisit.rs | 51 +++++------------------- compiler/rustc_lint/src/late.rs | 19 ++------- compiler/rustc_lint/src/levels.rs | 9 +---- compiler/rustc_mir_transform/src/lib.rs | 10 +---- compiler/rustc_passes/src/check_attr.rs | 9 +---- compiler/rustc_passes/src/dead.rs | 9 +---- compiler/rustc_passes/src/hir_stats.rs | 9 +---- compiler/rustc_passes/src/stability.rs | 10 ++--- compiler/rustc_privacy/src/lib.rs | 9 +---- src/librustdoc/doctest.rs | 9 +---- 11 files changed, 32 insertions(+), 116 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/index.rs b/compiler/rustc_ast_lowering/src/index.rs index d5af74d47fd..e08c1d063c1 100644 --- a/compiler/rustc_ast_lowering/src/index.rs +++ b/compiler/rustc_ast_lowering/src/index.rs @@ -295,14 +295,14 @@ fn visit_lifetime(&mut self, lifetime: &'hir Lifetime) { self.insert(lifetime.span, lifetime.hir_id, Node::Lifetime(lifetime)); } - fn visit_variant(&mut self, v: &'hir Variant<'hir>, g: &'hir Generics<'hir>, item_id: HirId) { + fn visit_variant(&mut self, v: &'hir Variant<'hir>) { self.insert(v.span, v.id, Node::Variant(v)); self.with_parent(v.id, |this| { // Register the constructor of this variant. if let Some(ctor_hir_id) = v.data.ctor_hir_id() { this.insert(v.span, ctor_hir_id, Node::Ctor(&v.data)); } - intravisit::walk_variant(this, v, g, item_id); + intravisit::walk_variant(this, v); }); } diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index e676acebe35..cd283e7651b 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -385,30 +385,17 @@ fn visit_param_bound(&mut self, bounds: &'v GenericBound<'v>) { fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef<'v>, m: TraitBoundModifier) { walk_poly_trait_ref(self, t, m) } - fn visit_variant_data( - &mut self, - s: &'v VariantData<'v>, - _: Symbol, - _: &'v Generics<'v>, - _parent_id: HirId, - _: Span, - ) { + fn visit_variant_data(&mut self, s: &'v VariantData<'v>) { walk_struct_def(self, s) } fn visit_field_def(&mut self, s: &'v FieldDef<'v>) { walk_field_def(self, s) } - fn visit_enum_def( - &mut self, - enum_definition: &'v EnumDef<'v>, - generics: &'v Generics<'v>, - item_id: HirId, - _: Span, - ) { - walk_enum_def(self, enum_definition, generics, item_id) + fn visit_enum_def(&mut self, enum_definition: &'v EnumDef<'v>, item_id: HirId, _: Span) { + walk_enum_def(self, enum_definition, item_id) } - fn visit_variant(&mut self, v: &'v Variant<'v>, g: &'v Generics<'v>, item_id: HirId) { - walk_variant(self, v, g, item_id) + fn visit_variant(&mut self, v: &'v Variant<'v>) { + walk_variant(self, v) } fn visit_label(&mut self, label: &'v Label) { walk_label(self, label) @@ -572,7 +559,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) { ItemKind::Enum(ref enum_definition, ref generics) => { visitor.visit_generics(generics); // `visit_enum_def()` takes care of visiting the `Item`'s `HirId`. - visitor.visit_enum_def(enum_definition, generics, item.hir_id(), item.span) + visitor.visit_enum_def(enum_definition, item.hir_id(), item.span) } ItemKind::Impl(Impl { unsafety: _, @@ -595,13 +582,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) { | ItemKind::Union(ref struct_definition, ref generics) => { visitor.visit_generics(generics); visitor.visit_id(item.hir_id()); - visitor.visit_variant_data( - struct_definition, - item.ident.name, - generics, - item.hir_id(), - item.span, - ); + visitor.visit_variant_data(struct_definition); } ItemKind::Trait(.., ref generics, bounds, trait_item_refs) => { visitor.visit_id(item.hir_id()); @@ -649,28 +630,16 @@ pub fn walk_use<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path<'v>, hir_id: pub fn walk_enum_def<'v, V: Visitor<'v>>( visitor: &mut V, enum_definition: &'v EnumDef<'v>, - generics: &'v Generics<'v>, item_id: HirId, ) { visitor.visit_id(item_id); - walk_list!(visitor, visit_variant, enum_definition.variants, generics, item_id); + walk_list!(visitor, visit_variant, enum_definition.variants); } -pub fn walk_variant<'v, V: Visitor<'v>>( - visitor: &mut V, - variant: &'v Variant<'v>, - generics: &'v Generics<'v>, - parent_item_id: HirId, -) { +pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V, variant: &'v Variant<'v>) { visitor.visit_ident(variant.ident); visitor.visit_id(variant.id); - visitor.visit_variant_data( - &variant.data, - variant.ident.name, - generics, - parent_item_id, - variant.span, - ); + visitor.visit_variant_data(&variant.data); walk_list!(visitor, visit_anon_const, &variant.disr_expr); } diff --git a/compiler/rustc_lint/src/late.rs b/compiler/rustc_lint/src/late.rs index a329b37519d..5188ac633d3 100644 --- a/compiler/rustc_lint/src/late.rs +++ b/compiler/rustc_lint/src/late.rs @@ -24,7 +24,6 @@ use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::lint::LintPass; -use rustc_span::symbol::Symbol; use rustc_span::Span; use std::any::Any; @@ -194,14 +193,7 @@ fn visit_fn( self.context.cached_typeck_results.set(old_cached_typeck_results); } - fn visit_variant_data( - &mut self, - s: &'tcx hir::VariantData<'tcx>, - _: Symbol, - _: &'tcx hir::Generics<'tcx>, - _: hir::HirId, - _: Span, - ) { + fn visit_variant_data(&mut self, s: &'tcx hir::VariantData<'tcx>) { lint_callback!(self, check_struct_def, s); hir_visit::walk_struct_def(self, s); } @@ -213,15 +205,10 @@ fn visit_field_def(&mut self, s: &'tcx hir::FieldDef<'tcx>) { }) } - fn visit_variant( - &mut self, - v: &'tcx hir::Variant<'tcx>, - g: &'tcx hir::Generics<'tcx>, - item_id: hir::HirId, - ) { + fn visit_variant(&mut self, v: &'tcx hir::Variant<'tcx>) { self.with_lint_attrs(v.id, |cx| { lint_callback!(cx, check_variant, v); - hir_visit::walk_variant(cx, v, g, item_id); + hir_visit::walk_variant(cx, v); }) } diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 00e96f20d1a..7ab9302d835 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -772,14 +772,9 @@ fn visit_field_def(&mut self, s: &'tcx hir::FieldDef<'tcx>) { }) } - fn visit_variant( - &mut self, - v: &'tcx hir::Variant<'tcx>, - g: &'tcx hir::Generics<'tcx>, - item_id: hir::HirId, - ) { + fn visit_variant(&mut self, v: &'tcx hir::Variant<'tcx>) { self.with_lint_attrs(v.id, |builder| { - intravisit::walk_variant(builder, v, g, item_id); + intravisit::walk_variant(builder, v); }) } diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 40dc9fe9a05..2a51af582f5 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -29,7 +29,6 @@ use rustc_middle::mir::{traversal, Body, ConstQualifs, MirPass, MirPhase, Promoted}; use rustc_middle::ty::query::Providers; use rustc_middle::ty::{self, TyCtxt, TypeVisitable}; -use rustc_span::{Span, Symbol}; #[macro_use] mod pass_manager; @@ -159,14 +158,7 @@ struct GatherCtors<'a, 'tcx> { set: &'a mut FxIndexSet, } impl<'tcx> Visitor<'tcx> for GatherCtors<'_, 'tcx> { - fn visit_variant_data( - &mut self, - v: &'tcx hir::VariantData<'tcx>, - _: Symbol, - _: &'tcx hir::Generics<'tcx>, - _: hir::HirId, - _: Span, - ) { + fn visit_variant_data(&mut self, v: &'tcx hir::VariantData<'tcx>) { if let hir::VariantData::Tuple(_, hir_id) = *v { self.set.insert(self.tcx.hir().local_def_id(hir_id)); } diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 6fea68ce8b3..f75fffb6871 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -2066,14 +2066,9 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { intravisit::walk_expr(self, expr) } - fn visit_variant( - &mut self, - variant: &'tcx hir::Variant<'tcx>, - generics: &'tcx hir::Generics<'tcx>, - item_id: HirId, - ) { + fn visit_variant(&mut self, variant: &'tcx hir::Variant<'tcx>) { self.check_attributes(variant.id, variant.span, Target::Variant, None); - intravisit::walk_variant(self, variant, generics, item_id) + intravisit::walk_variant(self, variant) } fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) { diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 1e2fbeb384c..625c854ea77 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -368,14 +368,7 @@ fn visit_nested_body(&mut self, body: hir::BodyId) { self.maybe_typeck_results = old_maybe_typeck_results; } - fn visit_variant_data( - &mut self, - def: &'tcx hir::VariantData<'tcx>, - _: Symbol, - _: &hir::Generics<'_>, - _: hir::HirId, - _: rustc_span::Span, - ) { + fn visit_variant_data(&mut self, def: &'tcx hir::VariantData<'tcx>) { let tcx = self.tcx; let has_repr_c = self.repr_has_repr_c; let has_repr_simd = self.repr_has_repr_simd; diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs index a3be827a7cc..4148d972806 100644 --- a/compiler/rustc_passes/src/hir_stats.rs +++ b/compiler/rustc_passes/src/hir_stats.rs @@ -203,14 +203,9 @@ fn visit_field_def(&mut self, s: &'v hir::FieldDef<'v>) { hir_visit::walk_field_def(self, s) } - fn visit_variant( - &mut self, - v: &'v hir::Variant<'v>, - g: &'v hir::Generics<'v>, - item_id: hir::HirId, - ) { + fn visit_variant(&mut self, v: &'v hir::Variant<'v>) { self.record("Variant", Id::None, v); - hir_visit::walk_variant(self, v, g, item_id) + hir_visit::walk_variant(self, v) } fn visit_lifetime(&mut self, lifetime: &'v hir::Lifetime) { diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index ca6a2ac3db3..e7ab47d7d28 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -10,7 +10,7 @@ use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID}; use rustc_hir::hir_id::CRATE_HIR_ID; use rustc_hir::intravisit::{self, Visitor}; -use rustc_hir::{FieldDef, Generics, HirId, Item, ItemKind, TraitRef, Ty, TyKind, Variant}; +use rustc_hir::{FieldDef, Item, ItemKind, TraitRef, Ty, TyKind, Variant}; use rustc_middle::hir::nested_filter; use rustc_middle::middle::privacy::AccessLevels; use rustc_middle::middle::stability::{AllowUnstable, DeprecationEntry, Index}; @@ -434,7 +434,7 @@ fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem<'tcx>) { ); } - fn visit_variant(&mut self, var: &'tcx Variant<'tcx>, g: &'tcx Generics<'tcx>, item_id: HirId) { + fn visit_variant(&mut self, var: &'tcx Variant<'tcx>) { self.annotate( self.tcx.hir().local_def_id(var.id), var.span, @@ -457,7 +457,7 @@ fn visit_variant(&mut self, var: &'tcx Variant<'tcx>, g: &'tcx Generics<'tcx>, i ); } - intravisit::walk_variant(v, var, g, item_id) + intravisit::walk_variant(v, var) }, ) } @@ -590,9 +590,9 @@ fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem<'tcx>) { intravisit::walk_impl_item(self, ii); } - fn visit_variant(&mut self, var: &'tcx Variant<'tcx>, g: &'tcx Generics<'tcx>, item_id: HirId) { + fn visit_variant(&mut self, var: &'tcx Variant<'tcx>) { self.check_missing_stability(self.tcx.hir().local_def_id(var.id), var.span); - intravisit::walk_variant(self, var, g, item_id); + intravisit::walk_variant(self, var); } fn visit_field_def(&mut self, s: &'tcx FieldDef<'tcx>) { diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index c28d0569d4c..f7c28eff55b 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -1625,15 +1625,10 @@ fn visit_ty(&mut self, t: &'tcx hir::Ty<'tcx>) { intravisit::walk_ty(self, t) } - fn visit_variant( - &mut self, - v: &'tcx hir::Variant<'tcx>, - g: &'tcx hir::Generics<'tcx>, - item_id: hir::HirId, - ) { + fn visit_variant(&mut self, v: &'tcx hir::Variant<'tcx>) { if self.access_levels.is_reachable(self.tcx.hir().local_def_id(v.id)) { self.in_variant = true; - intravisit::walk_variant(self, v, g, item_id); + intravisit::walk_variant(self, v); self.in_variant = false; } } diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 35964e3ba38..20ae102bc27 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -1289,14 +1289,9 @@ fn visit_foreign_item(&mut self, item: &'hir hir::ForeignItem<'_>) { }); } - fn visit_variant( - &mut self, - v: &'hir hir::Variant<'_>, - g: &'hir hir::Generics<'_>, - item_id: hir::HirId, - ) { + fn visit_variant(&mut self, v: &'hir hir::Variant<'_>) { self.visit_testable(v.ident.to_string(), v.id, v.span, |this| { - intravisit::walk_variant(this, v, g, item_id); + intravisit::walk_variant(this, v); }); } From 421125f30ac7772e733ebe4308956880d9b95dce Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 10 Aug 2022 12:02:48 +1000 Subject: [PATCH 2/4] Simplify `rustc_ast::visit::Visitor::visit_enum_def`. It's passed three arguments that are never used. --- compiler/rustc_ast/src/visit.rs | 19 ++++--------------- .../rustc_ast_passes/src/ast_validation.rs | 12 ++---------- compiler/rustc_ast_passes/src/node_count.rs | 10 ++-------- 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index d9594b323dd..c21d3246bd8 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -177,14 +177,8 @@ fn visit_variant_data(&mut self, s: &'ast VariantData) { fn visit_field_def(&mut self, s: &'ast FieldDef) { walk_field_def(self, s) } - fn visit_enum_def( - &mut self, - enum_definition: &'ast EnumDef, - generics: &'ast Generics, - item_id: NodeId, - _: Span, - ) { - walk_enum_def(self, enum_definition, generics, item_id) + fn visit_enum_def(&mut self, enum_definition: &'ast EnumDef) { + walk_enum_def(self, enum_definition) } fn visit_variant(&mut self, v: &'ast Variant) { walk_variant(self, v) @@ -334,7 +328,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) { } ItemKind::Enum(ref enum_definition, ref generics) => { visitor.visit_generics(generics); - visitor.visit_enum_def(enum_definition, generics, item.id, item.span) + visitor.visit_enum_def(enum_definition) } ItemKind::Impl(box Impl { defaultness: _, @@ -377,12 +371,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) { walk_list!(visitor, visit_attribute, &item.attrs); } -pub fn walk_enum_def<'a, V: Visitor<'a>>( - visitor: &mut V, - enum_definition: &'a EnumDef, - _: &'a Generics, - _: NodeId, -) { +pub fn walk_enum_def<'a, V: Visitor<'a>>(visitor: &mut V, enum_definition: &'a EnumDef) { walk_list!(visitor, visit_variant, &enum_definition.variants); } diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 60560b1c00e..31e961336a5 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -1547,16 +1547,8 @@ fn visit_variant_data(&mut self, s: &'a VariantData) { self.with_banned_assoc_ty_bound(|this| visit::walk_struct_def(this, s)) } - fn visit_enum_def( - &mut self, - enum_definition: &'a EnumDef, - generics: &'a Generics, - item_id: NodeId, - _: Span, - ) { - self.with_banned_assoc_ty_bound(|this| { - visit::walk_enum_def(this, enum_definition, generics, item_id) - }) + fn visit_enum_def(&mut self, enum_definition: &'a EnumDef) { + self.with_banned_assoc_ty_bound(|this| visit::walk_enum_def(this, enum_definition)) } fn visit_fn(&mut self, fk: FnKind<'a>, span: Span, id: NodeId) { diff --git a/compiler/rustc_ast_passes/src/node_count.rs b/compiler/rustc_ast_passes/src/node_count.rs index 9c7369c83e2..be44795b139 100644 --- a/compiler/rustc_ast_passes/src/node_count.rs +++ b/compiler/rustc_ast_passes/src/node_count.rs @@ -91,15 +91,9 @@ fn visit_field_def(&mut self, s: &FieldDef) { self.count += 1; walk_field_def(self, s) } - fn visit_enum_def( - &mut self, - enum_definition: &EnumDef, - generics: &Generics, - item_id: NodeId, - _: Span, - ) { + fn visit_enum_def(&mut self, enum_definition: &EnumDef) { self.count += 1; - walk_enum_def(self, enum_definition, generics, item_id) + walk_enum_def(self, enum_definition) } fn visit_variant(&mut self, v: &Variant) { self.count += 1; From 232bd80130b0f8f4354c9a69d88914aea21c6908 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 11 Aug 2022 11:05:26 +1000 Subject: [PATCH 3/4] Simplify `rustc_ast::visit::Visitor::visit_poly_trait_ref`. It is passed an argument that is never used. --- compiler/rustc_ast/src/visit.rs | 13 +++++-------- .../rustc_ast_lowering/src/lifetime_collector.rs | 9 +++------ compiler/rustc_ast_passes/src/ast_validation.rs | 4 ++-- compiler/rustc_ast_passes/src/node_count.rs | 4 ++-- .../src/deriving/generic/mod.rs | 8 ++------ compiler/rustc_lint/src/early.rs | 6 +++--- compiler/rustc_lint/src/passes.rs | 3 +-- compiler/rustc_resolve/src/late.rs | 2 +- src/tools/clippy/clippy_lints/src/unused_unit.rs | 2 +- 9 files changed, 20 insertions(+), 31 deletions(-) diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index c21d3246bd8..2abf6cc490e 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -168,8 +168,8 @@ fn visit_trait_ref(&mut self, t: &'ast TraitRef) { fn visit_param_bound(&mut self, bounds: &'ast GenericBound, _ctxt: BoundKind) { walk_param_bound(self, bounds) } - fn visit_poly_trait_ref(&mut self, t: &'ast PolyTraitRef, m: &'ast TraitBoundModifier) { - walk_poly_trait_ref(self, t, m) + fn visit_poly_trait_ref(&mut self, t: &'ast PolyTraitRef) { + walk_poly_trait_ref(self, t) } fn visit_variant_data(&mut self, s: &'ast VariantData) { walk_struct_def(self, s) @@ -281,11 +281,8 @@ pub fn walk_lifetime<'a, V: Visitor<'a>>(visitor: &mut V, lifetime: &'a Lifetime visitor.visit_ident(lifetime.ident); } -pub fn walk_poly_trait_ref<'a, V>( - visitor: &mut V, - trait_ref: &'a PolyTraitRef, - _: &TraitBoundModifier, -) where +pub fn walk_poly_trait_ref<'a, V>(visitor: &mut V, trait_ref: &'a PolyTraitRef) +where V: Visitor<'a>, { walk_list!(visitor, visit_generic_param, &trait_ref.bound_generic_params); @@ -587,7 +584,7 @@ pub fn walk_foreign_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a ForeignI pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a GenericBound) { match *bound { - GenericBound::Trait(ref typ, ref modifier) => visitor.visit_poly_trait_ref(typ, modifier), + GenericBound::Trait(ref typ, ref _modifier) => visitor.visit_poly_trait_ref(typ), GenericBound::Outlives(ref lifetime) => { visitor.visit_lifetime(lifetime, LifetimeCtxt::Bound) } diff --git a/compiler/rustc_ast_lowering/src/lifetime_collector.rs b/compiler/rustc_ast_lowering/src/lifetime_collector.rs index 81006e00fd4..8c67cebae55 100644 --- a/compiler/rustc_ast_lowering/src/lifetime_collector.rs +++ b/compiler/rustc_ast_lowering/src/lifetime_collector.rs @@ -1,9 +1,6 @@ use super::ResolverAstLoweringExt; use rustc_ast::visit::{self, BoundKind, LifetimeCtxt, Visitor}; -use rustc_ast::{ - FnRetTy, GenericBounds, Lifetime, NodeId, PathSegment, PolyTraitRef, TraitBoundModifier, Ty, - TyKind, -}; +use rustc_ast::{FnRetTy, GenericBounds, Lifetime, NodeId, PathSegment, PolyTraitRef, Ty, TyKind}; use rustc_hir::def::LifetimeRes; use rustc_middle::span_bug; use rustc_middle::ty::ResolverAstLowering; @@ -71,10 +68,10 @@ fn visit_path_segment(&mut self, path_span: Span, path_segment: &'ast PathSegmen visit::walk_path_segment(self, path_span, path_segment); } - fn visit_poly_trait_ref(&mut self, t: &'ast PolyTraitRef, m: &'ast TraitBoundModifier) { + fn visit_poly_trait_ref(&mut self, t: &'ast PolyTraitRef) { self.current_binders.push(t.trait_ref.ref_id); - visit::walk_poly_trait_ref(self, t, m); + visit::walk_poly_trait_ref(self, t); self.current_binders.pop(); } diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 31e961336a5..c8e78bc2623 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -1538,9 +1538,9 @@ fn visit_param_bound(&mut self, bound: &'a GenericBound, ctxt: BoundKind) { visit::walk_param_bound(self, bound) } - fn visit_poly_trait_ref(&mut self, t: &'a PolyTraitRef, m: &'a TraitBoundModifier) { + fn visit_poly_trait_ref(&mut self, t: &'a PolyTraitRef) { self.check_late_bound_lifetime_defs(&t.bound_generic_params); - visit::walk_poly_trait_ref(self, t, m); + visit::walk_poly_trait_ref(self, t); } fn visit_variant_data(&mut self, s: &'a VariantData) { diff --git a/compiler/rustc_ast_passes/src/node_count.rs b/compiler/rustc_ast_passes/src/node_count.rs index be44795b139..be3e46661bf 100644 --- a/compiler/rustc_ast_passes/src/node_count.rs +++ b/compiler/rustc_ast_passes/src/node_count.rs @@ -79,9 +79,9 @@ fn visit_param_bound(&mut self, bounds: &GenericBound, _ctxt: BoundKind) { self.count += 1; walk_param_bound(self, bounds) } - fn visit_poly_trait_ref(&mut self, t: &PolyTraitRef, m: &TraitBoundModifier) { + fn visit_poly_trait_ref(&mut self, t: &PolyTraitRef) { self.count += 1; - walk_poly_trait_ref(self, t, m) + walk_poly_trait_ref(self, t) } fn visit_variant_data(&mut self, s: &VariantData) { self.count += 1; diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index 735017aa5a8..ef64f52d40b 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -383,16 +383,12 @@ fn visit_ty(&mut self, ty: &'a ast::Ty) { } // Place bound generic params on a stack, to extract them when a type is encountered. - fn visit_poly_trait_ref( - &mut self, - trait_ref: &'a ast::PolyTraitRef, - modifier: &'a ast::TraitBoundModifier, - ) { + fn visit_poly_trait_ref(&mut self, trait_ref: &'a ast::PolyTraitRef) { let stack_len = self.bound_generic_params_stack.len(); self.bound_generic_params_stack .extend(trait_ref.bound_generic_params.clone().into_iter()); - visit::walk_poly_trait_ref(self, trait_ref, modifier); + visit::walk_poly_trait_ref(self, trait_ref); self.bound_generic_params_stack.truncate(stack_len); } diff --git a/compiler/rustc_lint/src/early.rs b/compiler/rustc_lint/src/early.rs index d13711c3ab5..cbf1a677555 100644 --- a/compiler/rustc_lint/src/early.rs +++ b/compiler/rustc_lint/src/early.rs @@ -233,9 +233,9 @@ fn visit_where_predicate(&mut self, p: &'a ast::WherePredicate) { ast_visit::walk_where_predicate(self, p); } - fn visit_poly_trait_ref(&mut self, t: &'a ast::PolyTraitRef, m: &'a ast::TraitBoundModifier) { - run_early_pass!(self, check_poly_trait_ref, t, m); - ast_visit::walk_poly_trait_ref(self, t, m); + fn visit_poly_trait_ref(&mut self, t: &'a ast::PolyTraitRef) { + run_early_pass!(self, check_poly_trait_ref, t); + ast_visit::walk_poly_trait_ref(self, t); } fn visit_assoc_item(&mut self, item: &'a ast::AssocItem, ctxt: ast_visit::AssocCtxt) { diff --git a/compiler/rustc_lint/src/passes.rs b/compiler/rustc_lint/src/passes.rs index cb7bd407ed4..413f06a97a2 100644 --- a/compiler/rustc_lint/src/passes.rs +++ b/compiler/rustc_lint/src/passes.rs @@ -156,8 +156,7 @@ macro_rules! early_lint_methods { fn check_generic_arg(a: &ast::GenericArg); fn check_generic_param(a: &ast::GenericParam); fn check_generics(a: &ast::Generics); - fn check_poly_trait_ref(a: &ast::PolyTraitRef, - b: &ast::TraitBoundModifier); + fn check_poly_trait_ref(a: &ast::PolyTraitRef); fn check_fn(a: rustc_ast::visit::FnKind<'_>, c: Span, d_: ast::NodeId); fn check_trait_item(a: &ast::AssocItem); fn check_impl_item(a: &ast::AssocItem); diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index ac8d26fb072..25e2852fd07 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -723,7 +723,7 @@ fn visit_ty(&mut self, ty: &'ast Ty) { self.diagnostic_metadata.current_trait_object = prev; self.diagnostic_metadata.current_type_path = prev_ty; } - fn visit_poly_trait_ref(&mut self, tref: &'ast PolyTraitRef, _: &'ast TraitBoundModifier) { + fn visit_poly_trait_ref(&mut self, tref: &'ast PolyTraitRef) { let span = tref.span.shrink_to_lo().to(tref.trait_ref.path.span.shrink_to_lo()); self.with_generic_param_rib( &tref.bound_generic_params, diff --git a/src/tools/clippy/clippy_lints/src/unused_unit.rs b/src/tools/clippy/clippy_lints/src/unused_unit.rs index 52585e59566..cd1d90e860b 100644 --- a/src/tools/clippy/clippy_lints/src/unused_unit.rs +++ b/src/tools/clippy/clippy_lints/src/unused_unit.rs @@ -89,7 +89,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) { } } - fn check_poly_trait_ref(&mut self, cx: &EarlyContext<'_>, poly: &ast::PolyTraitRef, _: &ast::TraitBoundModifier) { + fn check_poly_trait_ref(&mut self, cx: &EarlyContext<'_>, poly: &ast::PolyTraitRef) { let segments = &poly.trait_ref.path.segments; if_chain! { From b8b851f42e9a322179526f55d3fecf2a83bfeb11 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 11 Aug 2022 11:07:34 +1000 Subject: [PATCH 4/4] Simplify `rustc_hir::intravisit::Visitor::visit_enum_def`. It is passed an argument that is never used. --- compiler/rustc_hir/src/intravisit.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index cd283e7651b..51b1bfad8a0 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -391,7 +391,7 @@ fn visit_variant_data(&mut self, s: &'v VariantData<'v>) { fn visit_field_def(&mut self, s: &'v FieldDef<'v>) { walk_field_def(self, s) } - fn visit_enum_def(&mut self, enum_definition: &'v EnumDef<'v>, item_id: HirId, _: Span) { + fn visit_enum_def(&mut self, enum_definition: &'v EnumDef<'v>, item_id: HirId) { walk_enum_def(self, enum_definition, item_id) } fn visit_variant(&mut self, v: &'v Variant<'v>) { @@ -559,7 +559,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) { ItemKind::Enum(ref enum_definition, ref generics) => { visitor.visit_generics(generics); // `visit_enum_def()` takes care of visiting the `Item`'s `HirId`. - visitor.visit_enum_def(enum_definition, item.hir_id(), item.span) + visitor.visit_enum_def(enum_definition, item.hir_id()) } ItemKind::Impl(Impl { unsafety: _,