pub trait MutVisitor: Sized + MutVisitorResult<Result = ()> {
Show 68 methods
// Provided methods
fn visit_ident(&mut self, _: &mut Ident) -> Self::Result { ... }
fn visit_anon_const(&mut self, node: &mut AnonConst) { ... }
fn visit_arm(&mut self, node: &mut Arm) { ... }
fn visit_assoc_item_constraint(&mut self, node: &mut AssocItemConstraint) { ... }
fn visit_attribute(&mut self, node: &mut Attribute) { ... }
fn visit_block(&mut self, node: &mut Block) { ... }
fn visit_capture_by(&mut self, node: &mut CaptureBy) { ... }
fn visit_closure_binder(&mut self, node: &mut ClosureBinder) { ... }
fn visit_contract(&mut self, node: &mut FnContract) { ... }
fn visit_coroutine_kind(&mut self, node: &mut CoroutineKind) { ... }
fn visit_crate(&mut self, node: &mut Crate) { ... }
fn visit_expr(&mut self, node: &mut Expr) { ... }
fn visit_expr_field(&mut self, node: &mut ExprField) { ... }
fn visit_field_def(&mut self, node: &mut FieldDef) { ... }
fn visit_fn_decl(&mut self, node: &mut FnDecl) { ... }
fn visit_fn_header(&mut self, node: &mut FnHeader) { ... }
fn visit_fn_ret_ty(&mut self, node: &mut FnRetTy) { ... }
fn visit_foreign_mod(&mut self, node: &mut ForeignMod) { ... }
fn visit_format_args(&mut self, node: &mut FormatArgs) { ... }
fn visit_generic_arg(&mut self, node: &mut GenericArg) { ... }
fn visit_generic_args(&mut self, node: &mut GenericArgs) { ... }
fn visit_generic_param(&mut self, node: &mut GenericParam) { ... }
fn visit_generics(&mut self, node: &mut Generics) { ... }
fn visit_inline_asm(&mut self, node: &mut InlineAsm) { ... }
fn visit_inline_asm_sym(&mut self, node: &mut InlineAsmSym) { ... }
fn visit_label(&mut self, node: &mut Label) { ... }
fn visit_lifetime(&mut self, node: &mut Lifetime, _ctxt: LifetimeCtxt) { ... }
fn visit_local(&mut self, node: &mut Local) { ... }
fn visit_mac_call(&mut self, node: &mut MacCall) { ... }
fn visit_macro_def(&mut self, node: &mut MacroDef) { ... }
fn visit_param_bound(&mut self, node: &mut GenericBound, _ctxt: BoundKind) { ... }
fn visit_param(&mut self, node: &mut Param) { ... }
fn visit_pat_field(&mut self, node: &mut PatField) { ... }
fn visit_path(&mut self, node: &mut Path) { ... }
fn visit_path_segment(&mut self, node: &mut PathSegment) { ... }
fn visit_pat(&mut self, node: &mut Pat) { ... }
fn visit_poly_trait_ref(&mut self, node: &mut PolyTraitRef) { ... }
fn visit_precise_capturing_arg(&mut self, node: &mut PreciseCapturingArg) { ... }
fn visit_qself(&mut self, node: &mut QSelf) { ... }
fn visit_trait_ref(&mut self, node: &mut TraitRef) { ... }
fn visit_ty_pat(&mut self, node: &mut TyPat) { ... }
fn visit_ty(&mut self, node: &mut Ty) { ... }
fn visit_use_tree(&mut self, node: &mut UseTree) { ... }
fn visit_variant_data(&mut self, node: &mut VariantData) { ... }
fn visit_variant(&mut self, node: &mut Variant) { ... }
fn visit_vis(&mut self, node: &mut Visibility) { ... }
fn visit_where_predicate_kind(&mut self, node: &mut WherePredicateKind) { ... }
fn visit_where_predicate(&mut self, node: &mut WherePredicate) { ... }
fn visit_id(&mut self, _id: &mut NodeId) -> Self::Result { ... }
fn visit_method_receiver_expr(&mut self, ex: &mut Expr) -> Self::Result { ... }
fn visit_item(&mut self, item: &mut Item) -> Self::Result { ... }
fn visit_foreign_item(&mut self, item: &mut ForeignItem) -> Self::Result { ... }
fn visit_assoc_item(
&mut self,
item: &mut AssocItem,
ctxt: AssocCtxt,
) -> Self::Result { ... }
fn visit_fn(&mut self, fk: FnKind<'_>, _: Span, _: NodeId) -> Self::Result { ... }
fn visit_span(&mut self, _sp: &mut Span) { ... }
fn flat_map_foreign_item(
&mut self,
ni: P<ForeignItem>,
) -> SmallVec<[P<ForeignItem>; 1]> { ... }
fn flat_map_item(&mut self, i: P<Item>) -> SmallVec<[P<Item>; 1]> { ... }
fn flat_map_field_def(&mut self, fd: FieldDef) -> SmallVec<[FieldDef; 1]> { ... }
fn flat_map_assoc_item(
&mut self,
i: P<AssocItem>,
ctxt: AssocCtxt,
) -> SmallVec<[P<AssocItem>; 1]> { ... }
fn flat_map_stmt(&mut self, s: Stmt) -> SmallVec<[Stmt; 1]> { ... }
fn flat_map_arm(&mut self, arm: Arm) -> SmallVec<[Arm; 1]> { ... }
fn filter_map_expr(&mut self, e: P<Expr>) -> Option<P<Expr>> { ... }
fn flat_map_variant(&mut self, v: Variant) -> SmallVec<[Variant; 1]> { ... }
fn flat_map_param(&mut self, param: Param) -> SmallVec<[Param; 1]> { ... }
fn flat_map_generic_param(
&mut self,
param: GenericParam,
) -> SmallVec<[GenericParam; 1]> { ... }
fn flat_map_expr_field(&mut self, f: ExprField) -> SmallVec<[ExprField; 1]> { ... }
fn flat_map_where_predicate(
&mut self,
where_predicate: WherePredicate,
) -> SmallVec<[WherePredicate; 1]> { ... }
fn flat_map_pat_field(&mut self, fp: PatField) -> SmallVec<[PatField; 1]> { ... }
}
Expand description
Each method of this 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_item
method by default calls visit_mut::walk_item
.
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 this trait in case a new method with a new default implementation gets introduced.)
Every walk_*
method uses deconstruction to access fields of structs and
enums. This will result in a compile error if a field is added, which makes
it more likely the appropriate visit call will be added for it.
Provided Methods§
fn visit_ident(&mut self, _: &mut Ident) -> Self::Result
fn visit_anon_const(&mut self, node: &mut AnonConst)
fn visit_arm(&mut self, node: &mut Arm)
fn visit_assoc_item_constraint(&mut self, node: &mut AssocItemConstraint)
fn visit_attribute(&mut self, node: &mut Attribute)
fn visit_block(&mut self, node: &mut Block)
fn visit_capture_by(&mut self, node: &mut CaptureBy)
fn visit_closure_binder(&mut self, node: &mut ClosureBinder)
fn visit_contract(&mut self, node: &mut FnContract)
fn visit_coroutine_kind(&mut self, node: &mut CoroutineKind)
fn visit_crate(&mut self, node: &mut Crate)
fn visit_expr(&mut self, node: &mut Expr)
fn visit_expr_field(&mut self, node: &mut ExprField)
fn visit_field_def(&mut self, node: &mut FieldDef)
fn visit_fn_decl(&mut self, node: &mut FnDecl)
fn visit_fn_header(&mut self, node: &mut FnHeader)
fn visit_fn_ret_ty(&mut self, node: &mut FnRetTy)
fn visit_foreign_mod(&mut self, node: &mut ForeignMod)
fn visit_format_args(&mut self, node: &mut FormatArgs)
fn visit_generic_arg(&mut self, node: &mut GenericArg)
fn visit_generic_args(&mut self, node: &mut GenericArgs)
fn visit_generic_param(&mut self, node: &mut GenericParam)
fn visit_generics(&mut self, node: &mut Generics)
fn visit_inline_asm(&mut self, node: &mut InlineAsm)
fn visit_inline_asm_sym(&mut self, node: &mut InlineAsmSym)
fn visit_label(&mut self, node: &mut Label)
fn visit_lifetime(&mut self, node: &mut Lifetime, _ctxt: LifetimeCtxt)
fn visit_local(&mut self, node: &mut Local)
fn visit_mac_call(&mut self, node: &mut MacCall)
fn visit_macro_def(&mut self, node: &mut MacroDef)
fn visit_param_bound(&mut self, node: &mut GenericBound, _ctxt: BoundKind)
fn visit_param(&mut self, node: &mut Param)
fn visit_pat_field(&mut self, node: &mut PatField)
fn visit_path(&mut self, node: &mut Path)
fn visit_path_segment(&mut self, node: &mut PathSegment)
fn visit_pat(&mut self, node: &mut Pat)
fn visit_poly_trait_ref(&mut self, node: &mut PolyTraitRef)
fn visit_precise_capturing_arg(&mut self, node: &mut PreciseCapturingArg)
fn visit_qself(&mut self, node: &mut QSelf)
fn visit_trait_ref(&mut self, node: &mut TraitRef)
fn visit_ty_pat(&mut self, node: &mut TyPat)
fn visit_ty(&mut self, node: &mut Ty)
fn visit_use_tree(&mut self, node: &mut UseTree)
fn visit_variant_data(&mut self, node: &mut VariantData)
fn visit_variant(&mut self, node: &mut Variant)
fn visit_vis(&mut self, node: &mut Visibility)
fn visit_where_predicate_kind(&mut self, node: &mut WherePredicateKind)
fn visit_where_predicate(&mut self, node: &mut WherePredicate)
fn visit_id(&mut self, _id: &mut NodeId) -> Self::Result
Sourcefn visit_method_receiver_expr(&mut self, ex: &mut Expr) -> Self::Result
fn visit_method_receiver_expr(&mut self, ex: &mut Expr) -> Self::Result
This method is a hack to workaround unstable of stmt_expr_attributes
.
It can be removed once that feature is stabilized.
fn visit_item(&mut self, item: &mut Item) -> Self::Result
fn visit_foreign_item(&mut self, item: &mut ForeignItem) -> Self::Result
fn visit_assoc_item( &mut self, item: &mut AssocItem, ctxt: AssocCtxt, ) -> Self::Result
fn visit_fn(&mut self, fk: FnKind<'_>, _: Span, _: NodeId) -> Self::Result
fn visit_span(&mut self, _sp: &mut Span)
fn flat_map_foreign_item( &mut self, ni: P<ForeignItem>, ) -> SmallVec<[P<ForeignItem>; 1]>
fn flat_map_item(&mut self, i: P<Item>) -> SmallVec<[P<Item>; 1]>
fn flat_map_field_def(&mut self, fd: FieldDef) -> SmallVec<[FieldDef; 1]>
fn flat_map_assoc_item( &mut self, i: P<AssocItem>, ctxt: AssocCtxt, ) -> SmallVec<[P<AssocItem>; 1]>
fn flat_map_stmt(&mut self, s: Stmt) -> SmallVec<[Stmt; 1]>
fn flat_map_arm(&mut self, arm: Arm) -> SmallVec<[Arm; 1]>
fn filter_map_expr(&mut self, e: P<Expr>) -> Option<P<Expr>>
fn flat_map_variant(&mut self, v: Variant) -> SmallVec<[Variant; 1]>
fn flat_map_param(&mut self, param: Param) -> SmallVec<[Param; 1]>
fn flat_map_generic_param( &mut self, param: GenericParam, ) -> SmallVec<[GenericParam; 1]>
fn flat_map_expr_field(&mut self, f: ExprField) -> SmallVec<[ExprField; 1]>
fn flat_map_where_predicate( &mut self, where_predicate: WherePredicate, ) -> SmallVec<[WherePredicate; 1]>
fn flat_map_pat_field(&mut self, fp: PatField) -> SmallVec<[PatField; 1]>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.