Simplify rustc_ast::visit::Visitor::visit_poly_trait_ref
.
It is passed an argument that is never used.
This commit is contained in:
parent
421125f30a
commit
232bd80130
9 changed files with 20 additions and 31 deletions
|
@ -168,8 +168,8 @@ pub trait Visitor<'ast>: Sized {
|
||||||
fn visit_param_bound(&mut self, bounds: &'ast GenericBound, _ctxt: BoundKind) {
|
fn visit_param_bound(&mut self, bounds: &'ast GenericBound, _ctxt: BoundKind) {
|
||||||
walk_param_bound(self, bounds)
|
walk_param_bound(self, bounds)
|
||||||
}
|
}
|
||||||
fn visit_poly_trait_ref(&mut self, t: &'ast PolyTraitRef, m: &'ast TraitBoundModifier) {
|
fn visit_poly_trait_ref(&mut self, t: &'ast PolyTraitRef) {
|
||||||
walk_poly_trait_ref(self, t, m)
|
walk_poly_trait_ref(self, t)
|
||||||
}
|
}
|
||||||
fn visit_variant_data(&mut self, s: &'ast VariantData) {
|
fn visit_variant_data(&mut self, s: &'ast VariantData) {
|
||||||
walk_struct_def(self, s)
|
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);
|
visitor.visit_ident(lifetime.ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_poly_trait_ref<'a, V>(
|
pub fn walk_poly_trait_ref<'a, V>(visitor: &mut V, trait_ref: &'a PolyTraitRef)
|
||||||
visitor: &mut V,
|
where
|
||||||
trait_ref: &'a PolyTraitRef,
|
|
||||||
_: &TraitBoundModifier,
|
|
||||||
) where
|
|
||||||
V: Visitor<'a>,
|
V: Visitor<'a>,
|
||||||
{
|
{
|
||||||
walk_list!(visitor, visit_generic_param, &trait_ref.bound_generic_params);
|
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) {
|
pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a GenericBound) {
|
||||||
match *bound {
|
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) => {
|
GenericBound::Outlives(ref lifetime) => {
|
||||||
visitor.visit_lifetime(lifetime, LifetimeCtxt::Bound)
|
visitor.visit_lifetime(lifetime, LifetimeCtxt::Bound)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
use super::ResolverAstLoweringExt;
|
use super::ResolverAstLoweringExt;
|
||||||
use rustc_ast::visit::{self, BoundKind, LifetimeCtxt, Visitor};
|
use rustc_ast::visit::{self, BoundKind, LifetimeCtxt, Visitor};
|
||||||
use rustc_ast::{
|
use rustc_ast::{FnRetTy, GenericBounds, Lifetime, NodeId, PathSegment, PolyTraitRef, Ty, TyKind};
|
||||||
FnRetTy, GenericBounds, Lifetime, NodeId, PathSegment, PolyTraitRef, TraitBoundModifier, Ty,
|
|
||||||
TyKind,
|
|
||||||
};
|
|
||||||
use rustc_hir::def::LifetimeRes;
|
use rustc_hir::def::LifetimeRes;
|
||||||
use rustc_middle::span_bug;
|
use rustc_middle::span_bug;
|
||||||
use rustc_middle::ty::ResolverAstLowering;
|
use rustc_middle::ty::ResolverAstLowering;
|
||||||
|
@ -71,10 +68,10 @@ impl<'ast> Visitor<'ast> for LifetimeCollectVisitor<'ast> {
|
||||||
visit::walk_path_segment(self, path_span, path_segment);
|
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);
|
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();
|
self.current_binders.pop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1538,9 +1538,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
visit::walk_param_bound(self, bound)
|
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);
|
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) {
|
fn visit_variant_data(&mut self, s: &'a VariantData) {
|
||||||
|
|
|
@ -79,9 +79,9 @@ impl<'ast> Visitor<'ast> for NodeCounter {
|
||||||
self.count += 1;
|
self.count += 1;
|
||||||
walk_param_bound(self, bounds)
|
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;
|
self.count += 1;
|
||||||
walk_poly_trait_ref(self, t, m)
|
walk_poly_trait_ref(self, t)
|
||||||
}
|
}
|
||||||
fn visit_variant_data(&mut self, s: &VariantData) {
|
fn visit_variant_data(&mut self, s: &VariantData) {
|
||||||
self.count += 1;
|
self.count += 1;
|
||||||
|
|
|
@ -383,16 +383,12 @@ fn find_type_parameters(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Place bound generic params on a stack, to extract them when a type is encountered.
|
// Place bound generic params on a stack, to extract them when a type is encountered.
|
||||||
fn visit_poly_trait_ref(
|
fn visit_poly_trait_ref(&mut self, trait_ref: &'a ast::PolyTraitRef) {
|
||||||
&mut self,
|
|
||||||
trait_ref: &'a ast::PolyTraitRef,
|
|
||||||
modifier: &'a ast::TraitBoundModifier,
|
|
||||||
) {
|
|
||||||
let stack_len = self.bound_generic_params_stack.len();
|
let stack_len = self.bound_generic_params_stack.len();
|
||||||
self.bound_generic_params_stack
|
self.bound_generic_params_stack
|
||||||
.extend(trait_ref.bound_generic_params.clone().into_iter());
|
.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);
|
self.bound_generic_params_stack.truncate(stack_len);
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,9 +233,9 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
|
||||||
ast_visit::walk_where_predicate(self, p);
|
ast_visit::walk_where_predicate(self, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_poly_trait_ref(&mut self, t: &'a ast::PolyTraitRef, m: &'a ast::TraitBoundModifier) {
|
fn visit_poly_trait_ref(&mut self, t: &'a ast::PolyTraitRef) {
|
||||||
run_early_pass!(self, check_poly_trait_ref, t, m);
|
run_early_pass!(self, check_poly_trait_ref, t);
|
||||||
ast_visit::walk_poly_trait_ref(self, t, m);
|
ast_visit::walk_poly_trait_ref(self, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_assoc_item(&mut self, item: &'a ast::AssocItem, ctxt: ast_visit::AssocCtxt) {
|
fn visit_assoc_item(&mut self, item: &'a ast::AssocItem, ctxt: ast_visit::AssocCtxt) {
|
||||||
|
|
|
@ -156,8 +156,7 @@ macro_rules! early_lint_methods {
|
||||||
fn check_generic_arg(a: &ast::GenericArg);
|
fn check_generic_arg(a: &ast::GenericArg);
|
||||||
fn check_generic_param(a: &ast::GenericParam);
|
fn check_generic_param(a: &ast::GenericParam);
|
||||||
fn check_generics(a: &ast::Generics);
|
fn check_generics(a: &ast::Generics);
|
||||||
fn check_poly_trait_ref(a: &ast::PolyTraitRef,
|
fn check_poly_trait_ref(a: &ast::PolyTraitRef);
|
||||||
b: &ast::TraitBoundModifier);
|
|
||||||
fn check_fn(a: rustc_ast::visit::FnKind<'_>, c: Span, d_: ast::NodeId);
|
fn check_fn(a: rustc_ast::visit::FnKind<'_>, c: Span, d_: ast::NodeId);
|
||||||
fn check_trait_item(a: &ast::AssocItem);
|
fn check_trait_item(a: &ast::AssocItem);
|
||||||
fn check_impl_item(a: &ast::AssocItem);
|
fn check_impl_item(a: &ast::AssocItem);
|
||||||
|
|
|
@ -723,7 +723,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
|
||||||
self.diagnostic_metadata.current_trait_object = prev;
|
self.diagnostic_metadata.current_trait_object = prev;
|
||||||
self.diagnostic_metadata.current_type_path = prev_ty;
|
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());
|
let span = tref.span.shrink_to_lo().to(tref.trait_ref.path.span.shrink_to_lo());
|
||||||
self.with_generic_param_rib(
|
self.with_generic_param_rib(
|
||||||
&tref.bound_generic_params,
|
&tref.bound_generic_params,
|
||||||
|
|
|
@ -89,7 +89,7 @@ impl EarlyLintPass for UnusedUnit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
let segments = &poly.trait_ref.path.segments;
|
||||||
|
|
||||||
if_chain! {
|
if_chain! {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue