Trait rustc::hir::intravisit::Visitor
[−]
[src]
pub trait Visitor<'v>: Sized { fn visit_nested_item(&mut self, id: ItemId) { ... } fn visit_item(&mut self, i: &'v Item) { ... } fn visit_name(&mut self, _span: Span, _name: Name) { ... } fn visit_mod(&mut self, m: &'v Mod, _s: Span, _n: NodeId) { ... } fn visit_foreign_item(&mut self, i: &'v ForeignItem) { ... } fn visit_local(&mut self, l: &'v Local) { ... } fn visit_block(&mut self, b: &'v Block) { ... } fn visit_stmt(&mut self, s: &'v Stmt) { ... } fn visit_arm(&mut self, a: &'v Arm) { ... } fn visit_pat(&mut self, p: &'v Pat) { ... } fn visit_decl(&mut self, d: &'v Decl) { ... } fn visit_expr(&mut self, ex: &'v Expr) { ... } fn visit_expr_post(&mut self, _ex: &'v Expr) { ... } fn visit_ty(&mut self, t: &'v Ty) { ... } fn visit_generics(&mut self, g: &'v Generics) { ... } fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, b: &'v Block, s: Span, _: NodeId) { ... } fn visit_trait_item(&mut self, ti: &'v TraitItem) { ... } fn visit_impl_item(&mut self, ii: &'v ImplItem) { ... } fn visit_trait_ref(&mut self, t: &'v TraitRef) { ... } fn visit_ty_param_bound(&mut self, bounds: &'v TyParamBound) { ... } fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef, m: &'v TraitBoundModifier) { ... } fn visit_variant_data(&mut self, s: &'v VariantData, _: Name, _: &'v Generics, _: NodeId, _: Span) { ... } fn visit_struct_field(&mut self, s: &'v StructField) { ... } fn visit_enum_def(&mut self, enum_definition: &'v EnumDef, generics: &'v Generics, item_id: NodeId, _: Span) { ... } fn visit_variant(&mut self, v: &'v Variant, g: &'v Generics, item_id: NodeId) { ... } fn visit_lifetime(&mut self, lifetime: &'v Lifetime) { ... } fn visit_lifetime_def(&mut self, lifetime: &'v LifetimeDef) { ... } fn visit_path(&mut self, path: &'v Path, _id: NodeId) { ... } fn visit_path_list_item(&mut self, prefix: &'v Path, item: &'v PathListItem) { ... } fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment) { ... } fn visit_path_parameters(&mut self, path_span: Span, path_parameters: &'v PathParameters) { ... } fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding) { ... } fn visit_attribute(&mut self, _attr: &'v Attribute) { ... } fn visit_macro_def(&mut self, macro_def: &'v MacroDef) { ... } fn visit_vis(&mut self, vis: &'v Visibility) { ... } }
rustc_private
)Each method of the Visitor trait is a hook to be potentially
overridden. Each method's default implementation recursively visits
the substructure of the input via the corresponding walk
method;
e.g. the visit_mod
method by default calls intravisit::walk_mod
.
Note that this visitor does NOT visit nested items by default
(this is why the module is called intravisit
, to distinguish it
from the AST's visit
module, which acts differently). If you
simply want to visit all items in the crate in some order, you
should call Crate::visit_all_items
. Otherwise, see the comment
on visit_nested_item
for details on how to visit nested items.
If you want to ensure that your code handles every variant
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.)
Provided Methods
fn visit_nested_item(&mut self, id: ItemId)
rustc_private
)Invoked when a nested item is encountered. By default, does
nothing. If you want a deep walk, you need to override to
fetch the item contents. But most of the time, it is easier
(and better) to invoke Crate::visit_all_items
, which visits
all items in the crate in some order (but doesn't respect
nesting).
fn visit_item(&mut self, i: &'v Item)
rustc_private
)Visit the top-level item and (optionally) nested items. See
visit_nested_item
for details.
fn visit_name(&mut self, _span: Span, _name: Name)
rustc_private
)fn visit_mod(&mut self, m: &'v Mod, _s: Span, _n: NodeId)
rustc_private
)fn visit_foreign_item(&mut self, i: &'v ForeignItem)
rustc_private
)fn visit_local(&mut self, l: &'v Local)
rustc_private
)fn visit_block(&mut self, b: &'v Block)
rustc_private
)fn visit_stmt(&mut self, s: &'v Stmt)
rustc_private
)fn visit_arm(&mut self, a: &'v Arm)
rustc_private
)fn visit_pat(&mut self, p: &'v Pat)
rustc_private
)fn visit_decl(&mut self, d: &'v Decl)
rustc_private
)fn visit_expr(&mut self, ex: &'v Expr)
rustc_private
)fn visit_expr_post(&mut self, _ex: &'v Expr)
rustc_private
)fn visit_ty(&mut self, t: &'v Ty)
rustc_private
)fn visit_generics(&mut self, g: &'v Generics)
rustc_private
)fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, b: &'v Block, s: Span, _: NodeId)
rustc_private
)fn visit_trait_item(&mut self, ti: &'v TraitItem)
rustc_private
)fn visit_impl_item(&mut self, ii: &'v ImplItem)
rustc_private
)fn visit_trait_ref(&mut self, t: &'v TraitRef)
rustc_private
)fn visit_ty_param_bound(&mut self, bounds: &'v TyParamBound)
rustc_private
)fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef, m: &'v TraitBoundModifier)
rustc_private
)fn visit_variant_data(&mut self, s: &'v VariantData, _: Name, _: &'v Generics, _: NodeId, _: Span)
rustc_private
)fn visit_struct_field(&mut self, s: &'v StructField)
rustc_private
)fn visit_enum_def(&mut self, enum_definition: &'v EnumDef, generics: &'v Generics, item_id: NodeId, _: Span)
rustc_private
)fn visit_variant(&mut self, v: &'v Variant, g: &'v Generics, item_id: NodeId)
rustc_private
)fn visit_lifetime(&mut self, lifetime: &'v Lifetime)
rustc_private
)fn visit_lifetime_def(&mut self, lifetime: &'v LifetimeDef)
rustc_private
)fn visit_path(&mut self, path: &'v Path, _id: NodeId)
rustc_private
)fn visit_path_list_item(&mut self, prefix: &'v Path, item: &'v PathListItem)
rustc_private
)fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment)
rustc_private
)fn visit_path_parameters(&mut self, path_span: Span, path_parameters: &'v PathParameters)
rustc_private
)fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding)
rustc_private
)fn visit_attribute(&mut self, _attr: &'v Attribute)
rustc_private
)fn visit_macro_def(&mut self, macro_def: &'v MacroDef)
rustc_private
)fn visit_vis(&mut self, vis: &'v Visibility)
rustc_private
)Implementors
impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O>
impl<'a, 'tcx, 'v> Visitor<'v> for LateContext<'a, 'tcx>