Remove the type parameter from syntax::visit::Visitor
This commit is contained in:
parent
683e480ffe
commit
0644aba0b3
19 changed files with 169 additions and 188 deletions
|
@ -95,7 +95,7 @@ impl<'a> CheckAttrVisitor<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'v> Visitor<'v> for CheckAttrVisitor<'a> {
|
||||
impl<'a> Visitor for CheckAttrVisitor<'a> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
let target = Target::from_item(item);
|
||||
for attr in &item.attrs {
|
||||
|
|
|
@ -138,8 +138,8 @@ impl<'a> LoweringContext<'a> {
|
|||
lctx: &'lcx mut LoweringContext<'interner>,
|
||||
}
|
||||
|
||||
impl<'lcx, 'interner> Visitor<'lcx> for ItemLowerer<'lcx, 'interner> {
|
||||
fn visit_item(&mut self, item: &'lcx Item) {
|
||||
impl<'lcx, 'interner> Visitor for ItemLowerer<'lcx, 'interner> {
|
||||
fn visit_item(&mut self, item: &Item) {
|
||||
self.items.insert(item.id, self.lctx.lower_item(item));
|
||||
visit::walk_item(self, item);
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ impl<'ast> DefCollector<'ast> {
|
|||
self.parent_def = parent;
|
||||
}
|
||||
|
||||
fn visit_ast_const_integer(&mut self, expr: &'ast Expr) {
|
||||
fn visit_ast_const_integer(&mut self, expr: &Expr) {
|
||||
// Find the node which will be used after lowering.
|
||||
if let ExprKind::Paren(ref inner) = expr.node {
|
||||
return self.visit_ast_const_integer(inner);
|
||||
|
@ -124,8 +124,8 @@ impl<'ast> DefCollector<'ast> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'ast> visit::Visitor<'ast> for DefCollector<'ast> {
|
||||
fn visit_item(&mut self, i: &'ast Item) {
|
||||
impl<'ast> visit::Visitor for DefCollector<'ast> {
|
||||
fn visit_item(&mut self, i: &Item) {
|
||||
debug!("visit_item: {:?}", i);
|
||||
|
||||
// Pick the def data. This need not be unique, but the more
|
||||
|
@ -183,7 +183,7 @@ impl<'ast> visit::Visitor<'ast> for DefCollector<'ast> {
|
|||
});
|
||||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, foreign_item: &'ast ForeignItem) {
|
||||
fn visit_foreign_item(&mut self, foreign_item: &ForeignItem) {
|
||||
let def = self.create_def(foreign_item.id, DefPathData::ValueNs(foreign_item.ident.name));
|
||||
|
||||
self.with_parent(def, |this| {
|
||||
|
@ -191,7 +191,7 @@ impl<'ast> visit::Visitor<'ast> for DefCollector<'ast> {
|
|||
});
|
||||
}
|
||||
|
||||
fn visit_generics(&mut self, generics: &'ast Generics) {
|
||||
fn visit_generics(&mut self, generics: &Generics) {
|
||||
for ty_param in generics.ty_params.iter() {
|
||||
self.create_def(ty_param.id, DefPathData::TypeParam(ty_param.ident.name));
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ impl<'ast> visit::Visitor<'ast> for DefCollector<'ast> {
|
|||
visit::walk_generics(self, generics);
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'ast TraitItem) {
|
||||
fn visit_trait_item(&mut self, ti: &TraitItem) {
|
||||
let def_data = match ti.node {
|
||||
TraitItemKind::Method(..) | TraitItemKind::Const(..) =>
|
||||
DefPathData::ValueNs(ti.ident.name),
|
||||
|
@ -216,7 +216,7 @@ impl<'ast> visit::Visitor<'ast> for DefCollector<'ast> {
|
|||
});
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'ast ImplItem) {
|
||||
fn visit_impl_item(&mut self, ii: &ImplItem) {
|
||||
let def_data = match ii.node {
|
||||
ImplItemKind::Method(..) | ImplItemKind::Const(..) =>
|
||||
DefPathData::ValueNs(ii.ident.name),
|
||||
|
@ -234,7 +234,7 @@ impl<'ast> visit::Visitor<'ast> for DefCollector<'ast> {
|
|||
});
|
||||
}
|
||||
|
||||
fn visit_pat(&mut self, pat: &'ast Pat) {
|
||||
fn visit_pat(&mut self, pat: &Pat) {
|
||||
let parent_def = self.parent_def;
|
||||
|
||||
if let PatKind::Ident(_, id, _) = pat.node {
|
||||
|
@ -246,7 +246,7 @@ impl<'ast> visit::Visitor<'ast> for DefCollector<'ast> {
|
|||
self.parent_def = parent_def;
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'ast Expr) {
|
||||
fn visit_expr(&mut self, expr: &Expr) {
|
||||
let parent_def = self.parent_def;
|
||||
|
||||
if let ExprKind::Repeat(_, ref count) = expr.node {
|
||||
|
@ -262,18 +262,18 @@ impl<'ast> visit::Visitor<'ast> for DefCollector<'ast> {
|
|||
self.parent_def = parent_def;
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'ast Ty) {
|
||||
fn visit_ty(&mut self, ty: &Ty) {
|
||||
if let TyKind::FixedLengthVec(_, ref length) = ty.node {
|
||||
self.visit_ast_const_integer(length);
|
||||
}
|
||||
visit::walk_ty(self, ty);
|
||||
}
|
||||
|
||||
fn visit_lifetime_def(&mut self, def: &'ast LifetimeDef) {
|
||||
fn visit_lifetime_def(&mut self, def: &LifetimeDef) {
|
||||
self.create_def(def.lifetime.id, DefPathData::LifetimeDef(def.lifetime.name));
|
||||
}
|
||||
|
||||
fn visit_macro_def(&mut self, macro_def: &'ast MacroDef) {
|
||||
fn visit_macro_def(&mut self, macro_def: &MacroDef) {
|
||||
self.create_def(macro_def.id, DefPathData::MacroDef(macro_def.ident.name));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -905,7 +905,7 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
|
||||
impl<'a> ast_visit::Visitor for EarlyContext<'a> {
|
||||
fn visit_item(&mut self, it: &ast::Item) {
|
||||
self.with_lint_attrs(&it.attrs, |cx| {
|
||||
run_lints!(cx, check_item, early_passes, it);
|
||||
|
@ -939,8 +939,8 @@ impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
|
|||
ast_visit::walk_stmt(self, s);
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: ast_visit::FnKind<'v>, decl: &'v ast::FnDecl,
|
||||
body: &'v ast::Block, span: Span, id: ast::NodeId) {
|
||||
fn visit_fn(&mut self, fk: ast_visit::FnKind, decl: &ast::FnDecl,
|
||||
body: &ast::Block, span: Span, id: ast::NodeId) {
|
||||
run_lints!(self, check_fn, early_passes, fk, decl, body, span, id);
|
||||
ast_visit::walk_fn(self, fk, decl, body, span);
|
||||
run_lints!(self, check_fn_post, early_passes, fk, decl, body, span, id);
|
||||
|
|
|
@ -58,8 +58,8 @@ pub struct CrateReader<'a> {
|
|||
local_crate_name: String,
|
||||
}
|
||||
|
||||
impl<'a, 'ast> visit::Visitor<'ast> for LocalCrateReader<'a> {
|
||||
fn visit_item(&mut self, a: &'ast ast::Item) {
|
||||
impl<'a> visit::Visitor for LocalCrateReader<'a> {
|
||||
fn visit_item(&mut self, a: &ast::Item) {
|
||||
self.process_item(a);
|
||||
visit::walk_item(self, a);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ impl<'a> AstValidator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'v> Visitor<'v> for AstValidator<'a> {
|
||||
impl<'a> Visitor for AstValidator<'a> {
|
||||
fn visit_lifetime(&mut self, lt: &Lifetime) {
|
||||
if lt.name.as_str() == "'_" {
|
||||
self.session.add_lint(
|
||||
|
|
|
@ -29,7 +29,7 @@ struct CheckNoAsm<'a> {
|
|||
sess: &'a Session,
|
||||
}
|
||||
|
||||
impl<'a, 'v> Visitor<'v> for CheckNoAsm<'a> {
|
||||
impl<'a> Visitor for CheckNoAsm<'a> {
|
||||
fn visit_expr(&mut self, e: &ast::Expr) {
|
||||
match e.node {
|
||||
ast::ExprKind::InlineAsm(_) => span_err!(self.sess, e.span, E0472,
|
||||
|
|
|
@ -503,7 +503,7 @@ struct BuildReducedGraphVisitor<'a, 'b: 'a> {
|
|||
parent: Module<'b>,
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'v> Visitor<'v> for BuildReducedGraphVisitor<'a, 'b> {
|
||||
impl<'a, 'b> Visitor for BuildReducedGraphVisitor<'a, 'b> {
|
||||
fn visit_item(&mut self, item: &Item) {
|
||||
let old_parent = self.parent;
|
||||
self.resolver.build_reduced_graph_for_item(item, &mut self.parent);
|
||||
|
|
|
@ -71,7 +71,7 @@ impl<'a, 'b> UnusedImportCheckVisitor<'a, 'b> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'v> Visitor<'v> for UnusedImportCheckVisitor<'a, 'b> {
|
||||
impl<'a, 'b> Visitor for UnusedImportCheckVisitor<'a, 'b> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
visit::walk_item(self, item);
|
||||
// Ignore is_public import statements because there's no way to be sure
|
||||
|
|
|
@ -500,7 +500,7 @@ pub enum Namespace {
|
|||
ValueNS,
|
||||
}
|
||||
|
||||
impl<'a, 'v> Visitor<'v> for Resolver<'a> {
|
||||
impl<'a> Visitor for Resolver<'a> {
|
||||
fn visit_item(&mut self, item: &Item) {
|
||||
self.resolve_item(item);
|
||||
}
|
||||
|
@ -562,9 +562,9 @@ impl<'a, 'v> Visitor<'v> for Resolver<'a> {
|
|||
});
|
||||
}
|
||||
fn visit_fn(&mut self,
|
||||
function_kind: FnKind<'v>,
|
||||
declaration: &'v FnDecl,
|
||||
block: &'v Block,
|
||||
function_kind: FnKind,
|
||||
declaration: &FnDecl,
|
||||
block: &Block,
|
||||
_: Span,
|
||||
node_id: NodeId) {
|
||||
let rib_kind = match function_kind {
|
||||
|
|
|
@ -1013,7 +1013,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'v, 'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'v> for DumpVisitor<'l, 'tcx, 'll, D> {
|
||||
impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
use syntax::ast::ItemKind::*;
|
||||
self.process_macro_use(item.span, item.id);
|
||||
|
|
|
@ -686,7 +686,7 @@ impl PathCollector {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'v> Visitor<'v> for PathCollector {
|
||||
impl Visitor for PathCollector {
|
||||
fn visit_pat(&mut self, p: &ast::Pat) {
|
||||
match p.node {
|
||||
PatKind::Struct(ref path, _, _) => {
|
||||
|
|
|
@ -573,7 +573,7 @@ struct PatIdentFinder {
|
|||
ident_accumulator: Vec<ast::Ident>
|
||||
}
|
||||
|
||||
impl<'v> Visitor<'v> for PatIdentFinder {
|
||||
impl Visitor for PatIdentFinder {
|
||||
fn visit_pat(&mut self, pattern: &ast::Pat) {
|
||||
match *pattern {
|
||||
ast::Pat { id: _, node: PatKind::Ident(_, ref path1, ref inner), span: _ } => {
|
||||
|
@ -1226,7 +1226,7 @@ mod tests {
|
|||
path_accumulator: Vec<ast::Path> ,
|
||||
}
|
||||
|
||||
impl<'v> Visitor<'v> for PathExprFinderContext {
|
||||
impl Visitor for PathExprFinderContext {
|
||||
fn visit_expr(&mut self, expr: &ast::Expr) {
|
||||
if let ast::ExprKind::Path(None, ref p) = expr.node {
|
||||
self.path_accumulator.push(p.clone());
|
||||
|
@ -1248,7 +1248,7 @@ mod tests {
|
|||
ident_accumulator: Vec<ast::Ident>
|
||||
}
|
||||
|
||||
impl<'v> Visitor<'v> for IdentFinder {
|
||||
impl Visitor for IdentFinder {
|
||||
fn visit_ident(&mut self, _: codemap::Span, id: ast::Ident){
|
||||
self.ident_accumulator.push(id);
|
||||
}
|
||||
|
|
|
@ -849,7 +849,7 @@ macro_rules! gate_feature_post {
|
|||
}}
|
||||
}
|
||||
|
||||
impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
||||
impl<'a> Visitor for PostExpansionVisitor<'a> {
|
||||
fn visit_attribute(&mut self, attr: &ast::Attribute) {
|
||||
if !self.context.cm.span_allows_unstable(attr.span) {
|
||||
self.context.check_attribute(attr, false);
|
||||
|
@ -1045,9 +1045,9 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
|||
}
|
||||
|
||||
fn visit_fn(&mut self,
|
||||
fn_kind: FnKind<'v>,
|
||||
fn_decl: &'v ast::FnDecl,
|
||||
block: &'v ast::Block,
|
||||
fn_kind: FnKind,
|
||||
fn_decl: &ast::FnDecl,
|
||||
block: &ast::Block,
|
||||
span: Span,
|
||||
_node_id: NodeId) {
|
||||
// check for const fn declarations
|
||||
|
@ -1086,7 +1086,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
|||
visit::walk_fn(self, fn_kind, fn_decl, block, span);
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'v ast::TraitItem) {
|
||||
fn visit_trait_item(&mut self, ti: &ast::TraitItem) {
|
||||
match ti.node {
|
||||
ast::TraitItemKind::Const(..) => {
|
||||
gate_feature_post!(&self, associated_consts,
|
||||
|
@ -1107,7 +1107,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
|||
visit::walk_trait_item(self, ti);
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'v ast::ImplItem) {
|
||||
fn visit_impl_item(&mut self, ii: &ast::ImplItem) {
|
||||
if ii.defaultness == ast::Defaultness::Default {
|
||||
gate_feature_post!(&self, specialization,
|
||||
ii.span,
|
||||
|
@ -1130,7 +1130,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
|||
visit::walk_impl_item(self, ii);
|
||||
}
|
||||
|
||||
fn visit_vis(&mut self, vis: &'v ast::Visibility) {
|
||||
fn visit_vis(&mut self, vis: &ast::Visibility) {
|
||||
let span = match *vis {
|
||||
ast::Visibility::Crate(span) => span,
|
||||
ast::Visibility::Restricted { ref path, .. } => path.span,
|
||||
|
|
|
@ -991,8 +991,8 @@ mod tests {
|
|||
struct PatIdentVisitor {
|
||||
spans: Vec<Span>
|
||||
}
|
||||
impl<'v> ::visit::Visitor<'v> for PatIdentVisitor {
|
||||
fn visit_pat(&mut self, p: &'v ast::Pat) {
|
||||
impl ::visit::Visitor for PatIdentVisitor {
|
||||
fn visit_pat(&mut self, p: &ast::Pat) {
|
||||
match p.node {
|
||||
PatKind::Ident(_ , ref spannedident, _) => {
|
||||
self.spans.push(spannedident.span.clone());
|
||||
|
|
|
@ -44,7 +44,7 @@ struct ShowSpanVisitor<'a> {
|
|||
mode: Mode,
|
||||
}
|
||||
|
||||
impl<'a, 'v> Visitor<'v> for ShowSpanVisitor<'a> {
|
||||
impl<'a> Visitor for ShowSpanVisitor<'a> {
|
||||
fn visit_expr(&mut self, e: &ast::Expr) {
|
||||
if let Mode::Expression = self.mode {
|
||||
self.span_diagnostic.span_warn(e.span, "expression");
|
||||
|
|
|
@ -26,133 +26,133 @@ impl NodeCounter {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'v> Visitor<'v> for NodeCounter {
|
||||
impl Visitor for NodeCounter {
|
||||
fn visit_ident(&mut self, span: Span, ident: Ident) {
|
||||
self.count += 1;
|
||||
walk_ident(self, span, ident);
|
||||
}
|
||||
fn visit_mod(&mut self, m: &'v Mod, _s: Span, _n: NodeId) {
|
||||
fn visit_mod(&mut self, m: &Mod, _s: Span, _n: NodeId) {
|
||||
self.count += 1;
|
||||
walk_mod(self, m)
|
||||
}
|
||||
fn visit_foreign_item(&mut self, i: &'v ForeignItem) {
|
||||
fn visit_foreign_item(&mut self, i: &ForeignItem) {
|
||||
self.count += 1;
|
||||
walk_foreign_item(self, i)
|
||||
}
|
||||
fn visit_item(&mut self, i: &'v Item) {
|
||||
fn visit_item(&mut self, i: &Item) {
|
||||
self.count += 1;
|
||||
walk_item(self, i)
|
||||
}
|
||||
fn visit_local(&mut self, l: &'v Local) {
|
||||
fn visit_local(&mut self, l: &Local) {
|
||||
self.count += 1;
|
||||
walk_local(self, l)
|
||||
}
|
||||
fn visit_block(&mut self, b: &'v Block) {
|
||||
fn visit_block(&mut self, b: &Block) {
|
||||
self.count += 1;
|
||||
walk_block(self, b)
|
||||
}
|
||||
fn visit_stmt(&mut self, s: &'v Stmt) {
|
||||
fn visit_stmt(&mut self, s: &Stmt) {
|
||||
self.count += 1;
|
||||
walk_stmt(self, s)
|
||||
}
|
||||
fn visit_arm(&mut self, a: &'v Arm) {
|
||||
fn visit_arm(&mut self, a: &Arm) {
|
||||
self.count += 1;
|
||||
walk_arm(self, a)
|
||||
}
|
||||
fn visit_pat(&mut self, p: &'v Pat) {
|
||||
fn visit_pat(&mut self, p: &Pat) {
|
||||
self.count += 1;
|
||||
walk_pat(self, p)
|
||||
}
|
||||
fn visit_decl(&mut self, d: &'v Decl) {
|
||||
fn visit_decl(&mut self, d: &Decl) {
|
||||
self.count += 1;
|
||||
walk_decl(self, d)
|
||||
}
|
||||
fn visit_expr(&mut self, ex: &'v Expr) {
|
||||
fn visit_expr(&mut self, ex: &Expr) {
|
||||
self.count += 1;
|
||||
walk_expr(self, ex)
|
||||
}
|
||||
fn visit_ty(&mut self, t: &'v Ty) {
|
||||
fn visit_ty(&mut self, t: &Ty) {
|
||||
self.count += 1;
|
||||
walk_ty(self, t)
|
||||
}
|
||||
fn visit_generics(&mut self, g: &'v Generics) {
|
||||
fn visit_generics(&mut self, g: &Generics) {
|
||||
self.count += 1;
|
||||
walk_generics(self, g)
|
||||
}
|
||||
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, b: &'v Block, s: Span, _: NodeId) {
|
||||
fn visit_fn(&mut self, fk: FnKind, fd: &FnDecl, b: &Block, s: Span, _: NodeId) {
|
||||
self.count += 1;
|
||||
walk_fn(self, fk, fd, b, s)
|
||||
}
|
||||
fn visit_trait_item(&mut self, ti: &'v TraitItem) {
|
||||
fn visit_trait_item(&mut self, ti: &TraitItem) {
|
||||
self.count += 1;
|
||||
walk_trait_item(self, ti)
|
||||
}
|
||||
fn visit_impl_item(&mut self, ii: &'v ImplItem) {
|
||||
fn visit_impl_item(&mut self, ii: &ImplItem) {
|
||||
self.count += 1;
|
||||
walk_impl_item(self, ii)
|
||||
}
|
||||
fn visit_trait_ref(&mut self, t: &'v TraitRef) {
|
||||
fn visit_trait_ref(&mut self, t: &TraitRef) {
|
||||
self.count += 1;
|
||||
walk_trait_ref(self, t)
|
||||
}
|
||||
fn visit_ty_param_bound(&mut self, bounds: &'v TyParamBound) {
|
||||
fn visit_ty_param_bound(&mut self, bounds: &TyParamBound) {
|
||||
self.count += 1;
|
||||
walk_ty_param_bound(self, bounds)
|
||||
}
|
||||
fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef, m: &'v TraitBoundModifier) {
|
||||
fn visit_poly_trait_ref(&mut self, t: &PolyTraitRef, m: &TraitBoundModifier) {
|
||||
self.count += 1;
|
||||
walk_poly_trait_ref(self, t, m)
|
||||
}
|
||||
fn visit_variant_data(&mut self, s: &'v VariantData, _: Ident,
|
||||
_: &'v Generics, _: NodeId, _: Span) {
|
||||
fn visit_variant_data(&mut self, s: &VariantData, _: Ident,
|
||||
_: &Generics, _: NodeId, _: Span) {
|
||||
self.count += 1;
|
||||
walk_struct_def(self, s)
|
||||
}
|
||||
fn visit_struct_field(&mut self, s: &'v StructField) {
|
||||
fn visit_struct_field(&mut self, s: &StructField) {
|
||||
self.count += 1;
|
||||
walk_struct_field(self, s)
|
||||
}
|
||||
fn visit_enum_def(&mut self, enum_definition: &'v EnumDef,
|
||||
generics: &'v Generics, item_id: NodeId, _: Span) {
|
||||
fn visit_enum_def(&mut self, enum_definition: &EnumDef,
|
||||
generics: &Generics, item_id: NodeId, _: Span) {
|
||||
self.count += 1;
|
||||
walk_enum_def(self, enum_definition, generics, item_id)
|
||||
}
|
||||
fn visit_variant(&mut self, v: &'v Variant, g: &'v Generics, item_id: NodeId) {
|
||||
fn visit_variant(&mut self, v: &Variant, g: &Generics, item_id: NodeId) {
|
||||
self.count += 1;
|
||||
walk_variant(self, v, g, item_id)
|
||||
}
|
||||
fn visit_lifetime(&mut self, lifetime: &'v Lifetime) {
|
||||
fn visit_lifetime(&mut self, lifetime: &Lifetime) {
|
||||
self.count += 1;
|
||||
walk_lifetime(self, lifetime)
|
||||
}
|
||||
fn visit_lifetime_def(&mut self, lifetime: &'v LifetimeDef) {
|
||||
fn visit_lifetime_def(&mut self, lifetime: &LifetimeDef) {
|
||||
self.count += 1;
|
||||
walk_lifetime_def(self, lifetime)
|
||||
}
|
||||
fn visit_mac(&mut self, _mac: &'v Mac) {
|
||||
fn visit_mac(&mut self, _mac: &Mac) {
|
||||
self.count += 1;
|
||||
walk_mac(self, _mac)
|
||||
}
|
||||
fn visit_path(&mut self, path: &'v Path, _id: NodeId) {
|
||||
fn visit_path(&mut self, path: &Path, _id: NodeId) {
|
||||
self.count += 1;
|
||||
walk_path(self, path)
|
||||
}
|
||||
fn visit_path_list_item(&mut self, prefix: &'v Path, item: &'v PathListItem) {
|
||||
fn visit_path_list_item(&mut self, prefix: &Path, item: &PathListItem) {
|
||||
self.count += 1;
|
||||
walk_path_list_item(self, prefix, item)
|
||||
}
|
||||
fn visit_path_parameters(&mut self, path_span: Span, path_parameters: &'v PathParameters) {
|
||||
fn visit_path_parameters(&mut self, path_span: Span, path_parameters: &PathParameters) {
|
||||
self.count += 1;
|
||||
walk_path_parameters(self, path_span, path_parameters)
|
||||
}
|
||||
fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding) {
|
||||
fn visit_assoc_type_binding(&mut self, type_binding: &TypeBinding) {
|
||||
self.count += 1;
|
||||
walk_assoc_type_binding(self, type_binding)
|
||||
}
|
||||
fn visit_attribute(&mut self, _attr: &'v Attribute) {
|
||||
fn visit_attribute(&mut self, _attr: &Attribute) {
|
||||
self.count += 1;
|
||||
}
|
||||
fn visit_macro_def(&mut self, macro_def: &'v MacroDef) {
|
||||
fn visit_macro_def(&mut self, macro_def: &MacroDef) {
|
||||
self.count += 1;
|
||||
walk_macro_def(self, macro_def)
|
||||
}
|
||||
|
|
|
@ -49,57 +49,57 @@ pub enum FnKind<'a> {
|
|||
/// explicitly, you need to override each method. (And you also need
|
||||
/// to monitor future changes to `Visitor` in case a new method with a
|
||||
/// new default implementation gets introduced.)
|
||||
pub trait Visitor<'v> : Sized {
|
||||
pub trait Visitor: Sized {
|
||||
fn visit_name(&mut self, _span: Span, _name: Name) {
|
||||
// Nothing to do.
|
||||
}
|
||||
fn visit_ident(&mut self, span: Span, ident: Ident) {
|
||||
walk_ident(self, span, ident);
|
||||
}
|
||||
fn visit_mod(&mut self, m: &'v Mod, _s: Span, _n: NodeId) { walk_mod(self, m) }
|
||||
fn visit_foreign_item(&mut self, i: &'v ForeignItem) { walk_foreign_item(self, i) }
|
||||
fn visit_item(&mut self, i: &'v Item) { walk_item(self, i) }
|
||||
fn visit_local(&mut self, l: &'v Local) { walk_local(self, l) }
|
||||
fn visit_block(&mut self, b: &'v Block) { walk_block(self, b) }
|
||||
fn visit_stmt(&mut self, s: &'v Stmt) { walk_stmt(self, s) }
|
||||
fn visit_arm(&mut self, a: &'v Arm) { walk_arm(self, a) }
|
||||
fn visit_pat(&mut self, p: &'v Pat) { walk_pat(self, p) }
|
||||
fn visit_decl(&mut self, d: &'v Decl) { walk_decl(self, d) }
|
||||
fn visit_expr(&mut self, ex: &'v Expr) { walk_expr(self, ex) }
|
||||
fn visit_expr_post(&mut self, _ex: &'v Expr) { }
|
||||
fn visit_ty(&mut self, t: &'v Ty) { walk_ty(self, t) }
|
||||
fn visit_generics(&mut self, g: &'v Generics) { walk_generics(self, g) }
|
||||
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, b: &'v Block, s: Span, _: NodeId) {
|
||||
fn visit_mod(&mut self, m: &Mod, _s: Span, _n: NodeId) { walk_mod(self, m) }
|
||||
fn visit_foreign_item(&mut self, i: &ForeignItem) { walk_foreign_item(self, i) }
|
||||
fn visit_item(&mut self, i: &Item) { walk_item(self, i) }
|
||||
fn visit_local(&mut self, l: &Local) { walk_local(self, l) }
|
||||
fn visit_block(&mut self, b: &Block) { walk_block(self, b) }
|
||||
fn visit_stmt(&mut self, s: &Stmt) { walk_stmt(self, s) }
|
||||
fn visit_arm(&mut self, a: &Arm) { walk_arm(self, a) }
|
||||
fn visit_pat(&mut self, p: &Pat) { walk_pat(self, p) }
|
||||
fn visit_decl(&mut self, d: &Decl) { walk_decl(self, d) }
|
||||
fn visit_expr(&mut self, ex: &Expr) { walk_expr(self, ex) }
|
||||
fn visit_expr_post(&mut self, _ex: &Expr) { }
|
||||
fn visit_ty(&mut self, t: &Ty) { walk_ty(self, t) }
|
||||
fn visit_generics(&mut self, g: &Generics) { walk_generics(self, g) }
|
||||
fn visit_fn(&mut self, fk: FnKind, fd: &FnDecl, b: &Block, s: Span, _: NodeId) {
|
||||
walk_fn(self, fk, fd, b, s)
|
||||
}
|
||||
fn visit_trait_item(&mut self, ti: &'v TraitItem) { walk_trait_item(self, ti) }
|
||||
fn visit_impl_item(&mut self, ii: &'v ImplItem) { walk_impl_item(self, ii) }
|
||||
fn visit_trait_ref(&mut self, t: &'v TraitRef) { walk_trait_ref(self, t) }
|
||||
fn visit_ty_param_bound(&mut self, bounds: &'v TyParamBound) {
|
||||
fn visit_trait_item(&mut self, ti: &TraitItem) { walk_trait_item(self, ti) }
|
||||
fn visit_impl_item(&mut self, ii: &ImplItem) { walk_impl_item(self, ii) }
|
||||
fn visit_trait_ref(&mut self, t: &TraitRef) { walk_trait_ref(self, t) }
|
||||
fn visit_ty_param_bound(&mut self, bounds: &TyParamBound) {
|
||||
walk_ty_param_bound(self, bounds)
|
||||
}
|
||||
fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef, m: &'v TraitBoundModifier) {
|
||||
fn visit_poly_trait_ref(&mut self, t: &PolyTraitRef, m: &TraitBoundModifier) {
|
||||
walk_poly_trait_ref(self, t, m)
|
||||
}
|
||||
fn visit_variant_data(&mut self, s: &'v VariantData, _: Ident,
|
||||
_: &'v Generics, _: NodeId, _: Span) {
|
||||
fn visit_variant_data(&mut self, s: &VariantData, _: Ident,
|
||||
_: &Generics, _: NodeId, _: Span) {
|
||||
walk_struct_def(self, s)
|
||||
}
|
||||
fn visit_struct_field(&mut self, s: &'v StructField) { walk_struct_field(self, s) }
|
||||
fn visit_enum_def(&mut self, enum_definition: &'v EnumDef,
|
||||
generics: &'v Generics, item_id: NodeId, _: Span) {
|
||||
fn visit_struct_field(&mut self, s: &StructField) { walk_struct_field(self, s) }
|
||||
fn visit_enum_def(&mut self, enum_definition: &EnumDef,
|
||||
generics: &Generics, item_id: NodeId, _: Span) {
|
||||
walk_enum_def(self, enum_definition, generics, item_id)
|
||||
}
|
||||
fn visit_variant(&mut self, v: &'v Variant, g: &'v Generics, item_id: NodeId) {
|
||||
fn visit_variant(&mut self, v: &Variant, g: &Generics, item_id: NodeId) {
|
||||
walk_variant(self, v, g, item_id)
|
||||
}
|
||||
fn visit_lifetime(&mut self, lifetime: &'v Lifetime) {
|
||||
fn visit_lifetime(&mut self, lifetime: &Lifetime) {
|
||||
walk_lifetime(self, lifetime)
|
||||
}
|
||||
fn visit_lifetime_def(&mut self, lifetime: &'v LifetimeDef) {
|
||||
fn visit_lifetime_def(&mut self, lifetime: &LifetimeDef) {
|
||||
walk_lifetime_def(self, lifetime)
|
||||
}
|
||||
fn visit_mac(&mut self, _mac: &'v Mac) {
|
||||
fn visit_mac(&mut self, _mac: &Mac) {
|
||||
panic!("visit_mac disabled by default");
|
||||
// NB: see note about macros above.
|
||||
// if you really want a visitor that
|
||||
|
@ -107,26 +107,26 @@ pub trait Visitor<'v> : Sized {
|
|||
// definition in your trait impl:
|
||||
// visit::walk_mac(self, _mac)
|
||||
}
|
||||
fn visit_path(&mut self, path: &'v Path, _id: NodeId) {
|
||||
fn visit_path(&mut self, path: &Path, _id: NodeId) {
|
||||
walk_path(self, path)
|
||||
}
|
||||
fn visit_path_list_item(&mut self, prefix: &'v Path, item: &'v PathListItem) {
|
||||
fn visit_path_list_item(&mut self, prefix: &Path, item: &PathListItem) {
|
||||
walk_path_list_item(self, prefix, item)
|
||||
}
|
||||
fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment) {
|
||||
fn visit_path_segment(&mut self, path_span: Span, path_segment: &PathSegment) {
|
||||
walk_path_segment(self, path_span, path_segment)
|
||||
}
|
||||
fn visit_path_parameters(&mut self, path_span: Span, path_parameters: &'v PathParameters) {
|
||||
fn visit_path_parameters(&mut self, path_span: Span, path_parameters: &PathParameters) {
|
||||
walk_path_parameters(self, path_span, path_parameters)
|
||||
}
|
||||
fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding) {
|
||||
fn visit_assoc_type_binding(&mut self, type_binding: &TypeBinding) {
|
||||
walk_assoc_type_binding(self, type_binding)
|
||||
}
|
||||
fn visit_attribute(&mut self, _attr: &'v Attribute) {}
|
||||
fn visit_macro_def(&mut self, macro_def: &'v MacroDef) {
|
||||
fn visit_attribute(&mut self, _attr: &Attribute) {}
|
||||
fn visit_macro_def(&mut self, macro_def: &MacroDef) {
|
||||
walk_macro_def(self, macro_def)
|
||||
}
|
||||
fn visit_vis(&mut self, vis: &'v Visibility) {
|
||||
fn visit_vis(&mut self, vis: &Visibility) {
|
||||
walk_vis(self, vis)
|
||||
}
|
||||
}
|
||||
|
@ -145,46 +145,45 @@ macro_rules! walk_list {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_opt_name<'v, V: Visitor<'v>>(visitor: &mut V, span: Span, opt_name: Option<Name>) {
|
||||
pub fn walk_opt_name<V: Visitor>(visitor: &mut V, span: Span, opt_name: Option<Name>) {
|
||||
if let Some(name) = opt_name {
|
||||
visitor.visit_name(span, name);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_opt_ident<'v, V: Visitor<'v>>(visitor: &mut V, span: Span, opt_ident: Option<Ident>) {
|
||||
pub fn walk_opt_ident<V: Visitor>(visitor: &mut V, span: Span, opt_ident: Option<Ident>) {
|
||||
if let Some(ident) = opt_ident {
|
||||
visitor.visit_ident(span, ident);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_opt_sp_ident<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
opt_sp_ident: &Option<Spanned<Ident>>) {
|
||||
pub fn walk_opt_sp_ident<V: Visitor>(visitor: &mut V, opt_sp_ident: &Option<Spanned<Ident>>) {
|
||||
if let Some(ref sp_ident) = *opt_sp_ident {
|
||||
visitor.visit_ident(sp_ident.span, sp_ident.node);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_ident<'v, V: Visitor<'v>>(visitor: &mut V, span: Span, ident: Ident) {
|
||||
pub fn walk_ident<V: Visitor>(visitor: &mut V, span: Span, ident: Ident) {
|
||||
visitor.visit_name(span, ident.name);
|
||||
}
|
||||
|
||||
pub fn walk_crate<'v, V: Visitor<'v>>(visitor: &mut V, krate: &'v Crate) {
|
||||
pub fn walk_crate<V: Visitor>(visitor: &mut V, krate: &Crate) {
|
||||
visitor.visit_mod(&krate.module, krate.span, CRATE_NODE_ID);
|
||||
walk_list!(visitor, visit_attribute, &krate.attrs);
|
||||
walk_list!(visitor, visit_macro_def, &krate.exported_macros);
|
||||
}
|
||||
|
||||
pub fn walk_macro_def<'v, V: Visitor<'v>>(visitor: &mut V, macro_def: &'v MacroDef) {
|
||||
pub fn walk_macro_def<V: Visitor>(visitor: &mut V, macro_def: &MacroDef) {
|
||||
visitor.visit_ident(macro_def.span, macro_def.ident);
|
||||
walk_opt_ident(visitor, macro_def.span, macro_def.imported_from);
|
||||
walk_list!(visitor, visit_attribute, ¯o_def.attrs);
|
||||
}
|
||||
|
||||
pub fn walk_mod<'v, V: Visitor<'v>>(visitor: &mut V, module: &'v Mod) {
|
||||
pub fn walk_mod<V: Visitor>(visitor: &mut V, module: &Mod) {
|
||||
walk_list!(visitor, visit_item, &module.items);
|
||||
}
|
||||
|
||||
pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local) {
|
||||
pub fn walk_local<V: Visitor>(visitor: &mut V, local: &Local) {
|
||||
for attr in local.attrs.as_attr_slice() {
|
||||
visitor.visit_attribute(attr);
|
||||
}
|
||||
|
@ -193,33 +192,27 @@ pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local) {
|
|||
walk_list!(visitor, visit_expr, &local.init);
|
||||
}
|
||||
|
||||
pub fn walk_lifetime<'v, V: Visitor<'v>>(visitor: &mut V, lifetime: &'v Lifetime) {
|
||||
pub fn walk_lifetime<V: Visitor>(visitor: &mut V, lifetime: &Lifetime) {
|
||||
visitor.visit_name(lifetime.span, lifetime.name);
|
||||
}
|
||||
|
||||
pub fn walk_lifetime_def<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
lifetime_def: &'v LifetimeDef) {
|
||||
pub fn walk_lifetime_def<V: Visitor>(visitor: &mut V, lifetime_def: &LifetimeDef) {
|
||||
visitor.visit_lifetime(&lifetime_def.lifetime);
|
||||
walk_list!(visitor, visit_lifetime, &lifetime_def.bounds);
|
||||
}
|
||||
|
||||
pub fn walk_poly_trait_ref<'v, V>(visitor: &mut V,
|
||||
trait_ref: &'v PolyTraitRef,
|
||||
_modifier: &'v TraitBoundModifier)
|
||||
where V: Visitor<'v>
|
||||
pub fn walk_poly_trait_ref<V>(visitor: &mut V, trait_ref: &PolyTraitRef, _: &TraitBoundModifier)
|
||||
where V: Visitor,
|
||||
{
|
||||
walk_list!(visitor, visit_lifetime_def, &trait_ref.bound_lifetimes);
|
||||
visitor.visit_trait_ref(&trait_ref.trait_ref);
|
||||
}
|
||||
|
||||
pub fn walk_trait_ref<'v,V>(visitor: &mut V,
|
||||
trait_ref: &'v TraitRef)
|
||||
where V: Visitor<'v>
|
||||
{
|
||||
pub fn walk_trait_ref<V: Visitor>(visitor: &mut V, trait_ref: &TraitRef) {
|
||||
visitor.visit_path(&trait_ref.path, trait_ref.ref_id)
|
||||
}
|
||||
|
||||
pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
||||
pub fn walk_item<V: Visitor>(visitor: &mut V, item: &Item) {
|
||||
visitor.visit_vis(&item.vis);
|
||||
visitor.visit_ident(item.span, item.ident);
|
||||
match item.node {
|
||||
|
@ -298,17 +291,16 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
|||
walk_list!(visitor, visit_attribute, &item.attrs);
|
||||
}
|
||||
|
||||
pub fn walk_enum_def<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
enum_definition: &'v EnumDef,
|
||||
generics: &'v Generics,
|
||||
pub fn walk_enum_def<V: Visitor>(visitor: &mut V,
|
||||
enum_definition: &EnumDef,
|
||||
generics: &Generics,
|
||||
item_id: NodeId) {
|
||||
walk_list!(visitor, visit_variant, &enum_definition.variants, generics, item_id);
|
||||
}
|
||||
|
||||
pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
variant: &'v Variant,
|
||||
generics: &'v Generics,
|
||||
item_id: NodeId) {
|
||||
pub fn walk_variant<V>(visitor: &mut V, variant: &Variant, generics: &Generics, item_id: NodeId)
|
||||
where V: Visitor,
|
||||
{
|
||||
visitor.visit_ident(variant.span, variant.node.name);
|
||||
visitor.visit_variant_data(&variant.node.data, variant.node.name,
|
||||
generics, item_id, variant.span);
|
||||
|
@ -316,7 +308,7 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
|
|||
walk_list!(visitor, visit_attribute, &variant.node.attrs);
|
||||
}
|
||||
|
||||
pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
|
||||
pub fn walk_ty<V: Visitor>(visitor: &mut V, typ: &Ty) {
|
||||
match typ.node {
|
||||
TyKind::Vec(ref ty) | TyKind::Paren(ref ty) => {
|
||||
visitor.visit_ty(ty)
|
||||
|
@ -362,28 +354,25 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path) {
|
||||
pub fn walk_path<V: Visitor>(visitor: &mut V, path: &Path) {
|
||||
for segment in &path.segments {
|
||||
visitor.visit_path_segment(path.span, segment);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_path_list_item<'v, V: Visitor<'v>>(visitor: &mut V, _prefix: &'v Path,
|
||||
item: &'v PathListItem) {
|
||||
pub fn walk_path_list_item<V: Visitor>(visitor: &mut V, _prefix: &Path, item: &PathListItem) {
|
||||
walk_opt_ident(visitor, item.span, item.node.name());
|
||||
walk_opt_ident(visitor, item.span, item.node.rename());
|
||||
}
|
||||
|
||||
pub fn walk_path_segment<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
path_span: Span,
|
||||
segment: &'v PathSegment) {
|
||||
pub fn walk_path_segment<V: Visitor>(visitor: &mut V, path_span: Span, segment: &PathSegment) {
|
||||
visitor.visit_ident(path_span, segment.identifier);
|
||||
visitor.visit_path_parameters(path_span, &segment.parameters);
|
||||
}
|
||||
|
||||
pub fn walk_path_parameters<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
_path_span: Span,
|
||||
path_parameters: &'v PathParameters) {
|
||||
pub fn walk_path_parameters<V>(visitor: &mut V, _path_span: Span, path_parameters: &PathParameters)
|
||||
where V: Visitor,
|
||||
{
|
||||
match *path_parameters {
|
||||
PathParameters::AngleBracketed(ref data) => {
|
||||
walk_list!(visitor, visit_ty, &data.types);
|
||||
|
@ -397,13 +386,12 @@ pub fn walk_path_parameters<'v, V: Visitor<'v>>(visitor: &mut V,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
type_binding: &'v TypeBinding) {
|
||||
pub fn walk_assoc_type_binding<V: Visitor>(visitor: &mut V, type_binding: &TypeBinding) {
|
||||
visitor.visit_ident(type_binding.span, type_binding.ident);
|
||||
visitor.visit_ty(&type_binding.ty);
|
||||
}
|
||||
|
||||
pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
|
||||
pub fn walk_pat<V: Visitor>(visitor: &mut V, pattern: &Pat) {
|
||||
match pattern.node {
|
||||
PatKind::TupleStruct(ref path, ref children, _) => {
|
||||
visitor.visit_path(path, pattern.id);
|
||||
|
@ -449,8 +437,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
foreign_item: &'v ForeignItem) {
|
||||
pub fn walk_foreign_item<V: Visitor>(visitor: &mut V, foreign_item: &ForeignItem) {
|
||||
visitor.visit_vis(&foreign_item.vis);
|
||||
visitor.visit_ident(foreign_item.span, foreign_item.ident);
|
||||
|
||||
|
@ -465,8 +452,7 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V,
|
|||
walk_list!(visitor, visit_attribute, &foreign_item.attrs);
|
||||
}
|
||||
|
||||
pub fn walk_ty_param_bound<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
bound: &'v TyParamBound) {
|
||||
pub fn walk_ty_param_bound<V: Visitor>(visitor: &mut V, bound: &TyParamBound) {
|
||||
match *bound {
|
||||
TraitTyParamBound(ref typ, ref modifier) => {
|
||||
visitor.visit_poly_trait_ref(typ, modifier);
|
||||
|
@ -477,7 +463,7 @@ pub fn walk_ty_param_bound<'v, V: Visitor<'v>>(visitor: &mut V,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics) {
|
||||
pub fn walk_generics<V: Visitor>(visitor: &mut V, generics: &Generics) {
|
||||
for param in &generics.ty_params {
|
||||
visitor.visit_ident(param.span, param.ident);
|
||||
walk_list!(visitor, visit_ty_param_bound, ¶m.bounds);
|
||||
|
@ -511,13 +497,13 @@ pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FunctionRetTy) {
|
||||
pub fn walk_fn_ret_ty<V: Visitor>(visitor: &mut V, ret_ty: &FunctionRetTy) {
|
||||
if let FunctionRetTy::Ty(ref output_ty) = *ret_ty {
|
||||
visitor.visit_ty(output_ty)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: &'v FnDecl) {
|
||||
pub fn walk_fn_decl<V: Visitor>(visitor: &mut V, function_declaration: &FnDecl) {
|
||||
for argument in &function_declaration.inputs {
|
||||
visitor.visit_pat(&argument.pat);
|
||||
visitor.visit_ty(&argument.ty)
|
||||
|
@ -525,8 +511,7 @@ pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: &
|
|||
walk_fn_ret_ty(visitor, &function_declaration.output)
|
||||
}
|
||||
|
||||
pub fn walk_fn_kind<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
function_kind: FnKind<'v>) {
|
||||
pub fn walk_fn_kind<V: Visitor>(visitor: &mut V, function_kind: FnKind) {
|
||||
match function_kind {
|
||||
FnKind::ItemFn(_, generics, _, _, _, _) => {
|
||||
visitor.visit_generics(generics);
|
||||
|
@ -538,17 +523,15 @@ pub fn walk_fn_kind<'v, V: Visitor<'v>>(visitor: &mut V,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
function_kind: FnKind<'v>,
|
||||
function_declaration: &'v FnDecl,
|
||||
function_body: &'v Block,
|
||||
_span: Span) {
|
||||
walk_fn_decl(visitor, function_declaration);
|
||||
walk_fn_kind(visitor, function_kind);
|
||||
visitor.visit_block(function_body)
|
||||
pub fn walk_fn<V>(visitor: &mut V, kind: FnKind, declaration: &FnDecl, body: &Block, _span: Span)
|
||||
where V: Visitor,
|
||||
{
|
||||
walk_fn_decl(visitor, declaration);
|
||||
walk_fn_kind(visitor, kind);
|
||||
visitor.visit_block(body)
|
||||
}
|
||||
|
||||
pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v TraitItem) {
|
||||
pub fn walk_trait_item<V: Visitor>(visitor: &mut V, trait_item: &TraitItem) {
|
||||
visitor.visit_ident(trait_item.span, trait_item.ident);
|
||||
walk_list!(visitor, visit_attribute, &trait_item.attrs);
|
||||
match trait_item.node {
|
||||
|
@ -571,7 +554,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplItem) {
|
||||
pub fn walk_impl_item<V: Visitor>(visitor: &mut V, impl_item: &ImplItem) {
|
||||
visitor.visit_vis(&impl_item.vis);
|
||||
visitor.visit_ident(impl_item.span, impl_item.ident);
|
||||
walk_list!(visitor, visit_attribute, &impl_item.attrs);
|
||||
|
@ -593,25 +576,23 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_struct_def<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
struct_definition: &'v VariantData) {
|
||||
pub fn walk_struct_def<V: Visitor>(visitor: &mut V, struct_definition: &VariantData) {
|
||||
walk_list!(visitor, visit_struct_field, struct_definition.fields());
|
||||
}
|
||||
|
||||
pub fn walk_struct_field<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
struct_field: &'v StructField) {
|
||||
pub fn walk_struct_field<V: Visitor>(visitor: &mut V, struct_field: &StructField) {
|
||||
visitor.visit_vis(&struct_field.vis);
|
||||
walk_opt_ident(visitor, struct_field.span, struct_field.ident);
|
||||
visitor.visit_ty(&struct_field.ty);
|
||||
walk_list!(visitor, visit_attribute, &struct_field.attrs);
|
||||
}
|
||||
|
||||
pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) {
|
||||
pub fn walk_block<V: Visitor>(visitor: &mut V, block: &Block) {
|
||||
walk_list!(visitor, visit_stmt, &block.stmts);
|
||||
walk_list!(visitor, visit_expr, &block.expr);
|
||||
}
|
||||
|
||||
pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
|
||||
pub fn walk_stmt<V: Visitor>(visitor: &mut V, statement: &Stmt) {
|
||||
match statement.node {
|
||||
StmtKind::Decl(ref declaration, _) => visitor.visit_decl(declaration),
|
||||
StmtKind::Expr(ref expression, _) | StmtKind::Semi(ref expression, _) => {
|
||||
|
@ -626,18 +607,18 @@ pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_decl<'v, V: Visitor<'v>>(visitor: &mut V, declaration: &'v Decl) {
|
||||
pub fn walk_decl<V: Visitor>(visitor: &mut V, declaration: &Decl) {
|
||||
match declaration.node {
|
||||
DeclKind::Local(ref local) => visitor.visit_local(local),
|
||||
DeclKind::Item(ref item) => visitor.visit_item(item),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_mac<'v, V: Visitor<'v>>(_: &mut V, _: &'v Mac) {
|
||||
pub fn walk_mac<V: Visitor>(_: &mut V, _: &Mac) {
|
||||
// Empty!
|
||||
}
|
||||
|
||||
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
|
||||
pub fn walk_expr<V: Visitor>(visitor: &mut V, expression: &Expr) {
|
||||
for attr in expression.attrs.as_attr_slice() {
|
||||
visitor.visit_attribute(attr);
|
||||
}
|
||||
|
@ -787,14 +768,14 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
|
|||
visitor.visit_expr_post(expression)
|
||||
}
|
||||
|
||||
pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) {
|
||||
pub fn walk_arm<V: Visitor>(visitor: &mut V, arm: &Arm) {
|
||||
walk_list!(visitor, visit_pat, &arm.pats);
|
||||
walk_list!(visitor, visit_expr, &arm.guard);
|
||||
visitor.visit_expr(&arm.body);
|
||||
walk_list!(visitor, visit_attribute, &arm.attrs);
|
||||
}
|
||||
|
||||
pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) {
|
||||
pub fn walk_vis<V: Visitor>(visitor: &mut V, vis: &Visibility) {
|
||||
if let Visibility::Restricted { ref path, id } = *vis {
|
||||
visitor.visit_path(path, id);
|
||||
}
|
||||
|
|
|
@ -353,8 +353,8 @@ fn find_type_parameters(ty: &ast::Ty, ty_param_names: &[ast::Name]) -> Vec<P<ast
|
|||
types: Vec<P<ast::Ty>>,
|
||||
}
|
||||
|
||||
impl<'a> visit::Visitor<'a> for Visitor<'a> {
|
||||
fn visit_ty(&mut self, ty: &'a ast::Ty) {
|
||||
impl<'a> visit::Visitor for Visitor<'a> {
|
||||
fn visit_ty(&mut self, ty: &ast::Ty) {
|
||||
match ty.node {
|
||||
ast::TyKind::Path(_, ref path) if !path.global => {
|
||||
match path.segments.first() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue