Sync mut_visit function names with immut visit ones (s/noop_visit/walk/)

This commit is contained in:
Oli Scherer 2024-07-10 08:17:13 +00:00
parent 6f85f20520
commit 754bdef793
9 changed files with 226 additions and 235 deletions

View File

@ -36,7 +36,7 @@ impl<A: Array> ExpectOne<A> for SmallVec<A> {
}
pub trait NoopVisitItemKind {
fn noop_visit(
fn walk(
&mut self,
ctxt: Option<AssocCtxt>,
ident: Ident,
@ -86,35 +86,35 @@ pub trait MutVisitor: Sized {
// forget to add handling for it.
fn visit_crate(&mut self, c: &mut Crate) {
noop_visit_crate(c, self)
walk_crate(c, self)
}
fn visit_meta_list_item(&mut self, list_item: &mut NestedMetaItem) {
noop_visit_meta_list_item(list_item, self);
walk_meta_list_item(list_item, self);
}
fn visit_meta_item(&mut self, meta_item: &mut MetaItem) {
noop_visit_meta_item(meta_item, self);
walk_meta_item(meta_item, self);
}
fn visit_use_tree(&mut self, use_tree: &mut UseTree) {
noop_visit_use_tree(use_tree, self);
walk_use_tree(use_tree, self);
}
fn flat_map_foreign_item(&mut self, ni: P<ForeignItem>) -> SmallVec<[P<ForeignItem>; 1]> {
noop_flat_map_item(ni, None, self)
walk_flat_map_item(ni, None, self)
}
fn flat_map_item(&mut self, i: P<Item>) -> SmallVec<[P<Item>; 1]> {
noop_flat_map_item(i, None, self)
walk_flat_map_item(i, None, self)
}
fn visit_fn_header(&mut self, header: &mut FnHeader) {
noop_visit_fn_header(header, self);
walk_fn_header(header, self);
}
fn flat_map_field_def(&mut self, fd: FieldDef) -> SmallVec<[FieldDef; 1]> {
noop_flat_map_field_def(fd, self)
walk_flat_map_field_def(fd, self)
}
fn flat_map_assoc_item(
@ -122,48 +122,48 @@ pub trait MutVisitor: Sized {
i: P<AssocItem>,
ctxt: AssocCtxt,
) -> SmallVec<[P<AssocItem>; 1]> {
noop_flat_map_item(i, Some(ctxt), self)
walk_flat_map_item(i, Some(ctxt), self)
}
fn visit_fn_decl(&mut self, d: &mut P<FnDecl>) {
noop_visit_fn_decl(d, self);
walk_fn_decl(d, self);
}
/// `Span` and `NodeId` are mutated at the caller site.
fn visit_fn(&mut self, fk: FnKind<'_>, _: Span, _: NodeId) {
noop_visit_fn(fk, self)
walk_fn(fk, self)
}
fn visit_coroutine_kind(&mut self, a: &mut CoroutineKind) {
noop_visit_coroutine_kind(a, self);
walk_coroutine_kind(a, self);
}
fn visit_closure_binder(&mut self, b: &mut ClosureBinder) {
noop_visit_closure_binder(b, self);
walk_closure_binder(b, self);
}
fn visit_block(&mut self, b: &mut P<Block>) {
noop_visit_block(b, self);
walk_block(b, self);
}
fn flat_map_stmt(&mut self, s: Stmt) -> SmallVec<[Stmt; 1]> {
noop_flat_map_stmt(s, self)
walk_flat_map_stmt(s, self)
}
fn flat_map_arm(&mut self, arm: Arm) -> SmallVec<[Arm; 1]> {
noop_flat_map_arm(arm, self)
walk_flat_map_arm(arm, self)
}
fn visit_pat(&mut self, p: &mut P<Pat>) {
noop_visit_pat(p, self);
walk_pat(p, self);
}
fn visit_anon_const(&mut self, c: &mut AnonConst) {
noop_visit_anon_const(c, self);
walk_anon_const(c, self);
}
fn visit_expr(&mut self, e: &mut P<Expr>) {
noop_visit_expr(e, self);
walk_expr(e, self);
}
/// This method is a hack to workaround unstable of `stmt_expr_attributes`.
@ -177,127 +177,127 @@ pub trait MutVisitor: Sized {
}
fn visit_generic_arg(&mut self, arg: &mut GenericArg) {
noop_visit_generic_arg(arg, self);
walk_generic_arg(arg, self);
}
fn visit_ty(&mut self, t: &mut P<Ty>) {
noop_visit_ty(t, self);
walk_ty(t, self);
}
fn visit_lifetime(&mut self, l: &mut Lifetime) {
noop_visit_lifetime(l, self);
walk_lifetime(l, self);
}
fn visit_assoc_item_constraint(&mut self, c: &mut AssocItemConstraint) {
noop_visit_assoc_item_constraint(c, self);
walk_assoc_item_constraint(c, self);
}
fn visit_foreign_mod(&mut self, nm: &mut ForeignMod) {
noop_visit_foreign_mod(nm, self);
walk_foreign_mod(nm, self);
}
fn flat_map_variant(&mut self, v: Variant) -> SmallVec<[Variant; 1]> {
noop_flat_map_variant(v, self)
walk_flat_map_variant(v, self)
}
fn visit_ident(&mut self, i: &mut Ident) {
noop_visit_ident(i, self);
walk_ident(i, self);
}
fn visit_path(&mut self, p: &mut Path) {
noop_visit_path(p, self);
walk_path(self, p);
}
fn visit_path_segment(&mut self, p: &mut PathSegment) {
noop_visit_path_segment(p, self)
walk_path_segment(self, p)
}
fn visit_qself(&mut self, qs: &mut Option<P<QSelf>>) {
noop_visit_qself(qs, self);
walk_qself(qs, self);
}
fn visit_generic_args(&mut self, p: &mut GenericArgs) {
noop_visit_generic_args(p, self);
walk_generic_args(p, self);
}
fn visit_angle_bracketed_parameter_data(&mut self, p: &mut AngleBracketedArgs) {
noop_visit_angle_bracketed_parameter_data(p, self);
walk_angle_bracketed_parameter_data(p, self);
}
fn visit_parenthesized_parameter_data(&mut self, p: &mut ParenthesizedArgs) {
noop_visit_parenthesized_parameter_data(p, self);
walk_parenthesized_parameter_data(p, self);
}
fn visit_local(&mut self, l: &mut P<Local>) {
noop_visit_local(l, self);
walk_local(l, self);
}
fn visit_mac_call(&mut self, mac: &mut MacCall) {
noop_visit_mac(mac, self);
walk_mac(mac, self);
}
fn visit_macro_def(&mut self, def: &mut MacroDef) {
noop_visit_macro_def(def, self);
walk_macro_def(def, self);
}
fn visit_label(&mut self, label: &mut Label) {
noop_visit_label(label, self);
walk_label(label, self);
}
fn visit_attribute(&mut self, at: &mut Attribute) {
noop_visit_attribute(at, self);
walk_attribute(at, self);
}
fn flat_map_param(&mut self, param: Param) -> SmallVec<[Param; 1]> {
noop_flat_map_param(param, self)
walk_flat_map_param(param, self)
}
fn visit_generics(&mut self, generics: &mut Generics) {
noop_visit_generics(generics, self);
walk_generics(generics, self);
}
fn visit_trait_ref(&mut self, tr: &mut TraitRef) {
noop_visit_trait_ref(tr, self);
walk_trait_ref(tr, self);
}
fn visit_poly_trait_ref(&mut self, p: &mut PolyTraitRef) {
noop_visit_poly_trait_ref(p, self);
walk_poly_trait_ref(p, self);
}
fn visit_variant_data(&mut self, vdata: &mut VariantData) {
noop_visit_variant_data(vdata, self);
walk_variant_data(vdata, self);
}
fn flat_map_generic_param(&mut self, param: GenericParam) -> SmallVec<[GenericParam; 1]> {
noop_flat_map_generic_param(param, self)
walk_flat_map_generic_param(param, self)
}
fn visit_param_bound(&mut self, tpb: &mut GenericBound, _ctxt: BoundKind) {
noop_visit_param_bound(tpb, self);
walk_param_bound(tpb, self);
}
fn visit_precise_capturing_arg(&mut self, arg: &mut PreciseCapturingArg) {
noop_visit_precise_capturing_arg(arg, self);
walk_precise_capturing_arg(arg, self);
}
fn visit_mt(&mut self, mt: &mut MutTy) {
noop_visit_mt(mt, self);
walk_mt(mt, self);
}
fn flat_map_expr_field(&mut self, f: ExprField) -> SmallVec<[ExprField; 1]> {
noop_flat_map_expr_field(f, self)
walk_flat_map_expr_field(f, self)
}
fn visit_where_clause(&mut self, where_clause: &mut WhereClause) {
noop_visit_where_clause(where_clause, self);
walk_where_clause(where_clause, self);
}
fn visit_where_predicate(&mut self, where_predicate: &mut WherePredicate) {
noop_visit_where_predicate(where_predicate, self);
walk_where_predicate(where_predicate, self);
}
fn visit_vis(&mut self, vis: &mut Visibility) {
noop_visit_vis(vis, self);
walk_vis(vis, self);
}
fn visit_id(&mut self, _id: &mut NodeId) {
@ -309,23 +309,23 @@ pub trait MutVisitor: Sized {
}
fn flat_map_pat_field(&mut self, fp: PatField) -> SmallVec<[PatField; 1]> {
noop_flat_map_pat_field(fp, self)
walk_flat_map_pat_field(fp, self)
}
fn visit_inline_asm(&mut self, asm: &mut InlineAsm) {
noop_visit_inline_asm(asm, self)
walk_inline_asm(asm, self)
}
fn visit_inline_asm_sym(&mut self, sym: &mut InlineAsmSym) {
noop_visit_inline_asm_sym(sym, self)
walk_inline_asm_sym(sym, self)
}
fn visit_format_args(&mut self, fmt: &mut FormatArgs) {
noop_visit_format_args(fmt, self)
walk_format_args(fmt, self)
}
fn visit_capture_by(&mut self, capture_by: &mut CaptureBy) {
noop_visit_capture_by(capture_by, self)
walk_capture_by(capture_by, self)
}
}
@ -422,7 +422,7 @@ pub fn visit_delim_span<T: MutVisitor>(DelimSpan { open, close }: &mut DelimSpan
vis.visit_span(close);
}
pub fn noop_flat_map_pat_field<T: MutVisitor>(
pub fn walk_flat_map_pat_field<T: MutVisitor>(
mut fp: PatField,
vis: &mut T,
) -> SmallVec<[PatField; 1]> {
@ -435,7 +435,7 @@ pub fn noop_flat_map_pat_field<T: MutVisitor>(
smallvec![fp]
}
fn noop_visit_use_tree<T: MutVisitor>(use_tree: &mut UseTree, vis: &mut T) {
fn walk_use_tree<T: MutVisitor>(use_tree: &mut UseTree, vis: &mut T) {
let UseTree { prefix, kind, span } = use_tree;
vis.visit_path(prefix);
match kind {
@ -452,7 +452,7 @@ fn noop_visit_use_tree<T: MutVisitor>(use_tree: &mut UseTree, vis: &mut T) {
vis.visit_span(span);
}
pub fn noop_flat_map_arm<T: MutVisitor>(mut arm: Arm, vis: &mut T) -> SmallVec<[Arm; 1]> {
pub fn walk_flat_map_arm<T: MutVisitor>(mut arm: Arm, vis: &mut T) -> SmallVec<[Arm; 1]> {
let Arm { attrs, pat, guard, body, span, id, is_placeholder: _ } = &mut arm;
vis.visit_id(id);
visit_attrs(attrs, vis);
@ -463,7 +463,7 @@ pub fn noop_flat_map_arm<T: MutVisitor>(mut arm: Arm, vis: &mut T) -> SmallVec<[
smallvec![arm]
}
fn noop_visit_assoc_item_constraint<T: MutVisitor>(
fn walk_assoc_item_constraint<T: MutVisitor>(
AssocItemConstraint { id, ident, gen_args, kind, span }: &mut AssocItemConstraint,
vis: &mut T,
) {
@ -482,7 +482,7 @@ fn noop_visit_assoc_item_constraint<T: MutVisitor>(
vis.visit_span(span);
}
pub fn noop_visit_ty<T: MutVisitor>(ty: &mut P<Ty>, vis: &mut T) {
pub fn walk_ty<T: MutVisitor>(ty: &mut P<Ty>, vis: &mut T) {
let Ty { id, kind, span, tokens } = ty.deref_mut();
vis.visit_id(id);
match kind {
@ -534,13 +534,13 @@ pub fn noop_visit_ty<T: MutVisitor>(ty: &mut P<Ty>, vis: &mut T) {
vis.visit_span(span);
}
fn noop_visit_foreign_mod<T: MutVisitor>(foreign_mod: &mut ForeignMod, vis: &mut T) {
fn walk_foreign_mod<T: MutVisitor>(foreign_mod: &mut ForeignMod, vis: &mut T) {
let ForeignMod { safety, abi: _, items } = foreign_mod;
visit_safety(safety, vis);
items.flat_map_in_place(|item| vis.flat_map_foreign_item(item));
}
pub fn noop_flat_map_variant<T: MutVisitor>(
pub fn walk_flat_map_variant<T: MutVisitor>(
mut variant: Variant,
visitor: &mut T,
) -> SmallVec<[Variant; 1]> {
@ -555,18 +555,18 @@ pub fn noop_flat_map_variant<T: MutVisitor>(
smallvec![variant]
}
fn noop_visit_ident<T: MutVisitor>(Ident { name: _, span }: &mut Ident, vis: &mut T) {
fn walk_ident<T: MutVisitor>(Ident { name: _, span }: &mut Ident, vis: &mut T) {
vis.visit_span(span);
}
fn noop_visit_path_segment<T: MutVisitor>(segment: &mut PathSegment, vis: &mut T) {
fn walk_path_segment<T: MutVisitor>(vis: &mut T, segment: &mut PathSegment) {
let PathSegment { ident, id, args } = segment;
vis.visit_id(id);
vis.visit_ident(ident);
visit_opt(args, |args| vis.visit_generic_args(args));
}
fn noop_visit_path<T: MutVisitor>(Path { segments, span, tokens }: &mut Path, vis: &mut T) {
fn walk_path<T: MutVisitor>(vis: &mut T, Path { segments, span, tokens }: &mut Path) {
for segment in segments {
vis.visit_path_segment(segment);
}
@ -574,7 +574,7 @@ fn noop_visit_path<T: MutVisitor>(Path { segments, span, tokens }: &mut Path, vi
vis.visit_span(span);
}
fn noop_visit_qself<T: MutVisitor>(qself: &mut Option<P<QSelf>>, vis: &mut T) {
fn walk_qself<T: MutVisitor>(qself: &mut Option<P<QSelf>>, vis: &mut T) {
visit_opt(qself, |qself| {
let QSelf { ty, path_span, position: _ } = &mut **qself;
vis.visit_ty(ty);
@ -582,7 +582,7 @@ fn noop_visit_qself<T: MutVisitor>(qself: &mut Option<P<QSelf>>, vis: &mut T) {
})
}
fn noop_visit_generic_args<T: MutVisitor>(generic_args: &mut GenericArgs, vis: &mut T) {
fn walk_generic_args<T: MutVisitor>(generic_args: &mut GenericArgs, vis: &mut T) {
match generic_args {
GenericArgs::AngleBracketed(data) => vis.visit_angle_bracketed_parameter_data(data),
GenericArgs::Parenthesized(data) => vis.visit_parenthesized_parameter_data(data),
@ -590,7 +590,7 @@ fn noop_visit_generic_args<T: MutVisitor>(generic_args: &mut GenericArgs, vis: &
}
}
fn noop_visit_generic_arg<T: MutVisitor>(arg: &mut GenericArg, vis: &mut T) {
fn walk_generic_arg<T: MutVisitor>(arg: &mut GenericArg, vis: &mut T) {
match arg {
GenericArg::Lifetime(lt) => vis.visit_lifetime(lt),
GenericArg::Type(ty) => vis.visit_ty(ty),
@ -598,10 +598,7 @@ fn noop_visit_generic_arg<T: MutVisitor>(arg: &mut GenericArg, vis: &mut T) {
}
}
fn noop_visit_angle_bracketed_parameter_data<T: MutVisitor>(
data: &mut AngleBracketedArgs,
vis: &mut T,
) {
fn walk_angle_bracketed_parameter_data<T: MutVisitor>(data: &mut AngleBracketedArgs, vis: &mut T) {
let AngleBracketedArgs { args, span } = data;
visit_thin_vec(args, |arg| match arg {
AngleBracketedArg::Arg(arg) => vis.visit_generic_arg(arg),
@ -610,18 +607,15 @@ fn noop_visit_angle_bracketed_parameter_data<T: MutVisitor>(
vis.visit_span(span);
}
fn noop_visit_parenthesized_parameter_data<T: MutVisitor>(
args: &mut ParenthesizedArgs,
vis: &mut T,
) {
fn walk_parenthesized_parameter_data<T: MutVisitor>(args: &mut ParenthesizedArgs, vis: &mut T) {
let ParenthesizedArgs { inputs, output, span, inputs_span } = args;
visit_thin_vec(inputs, |input| vis.visit_ty(input));
noop_visit_fn_ret_ty(output, vis);
walk_fn_ret_ty(output, vis);
vis.visit_span(span);
vis.visit_span(inputs_span);
}
fn noop_visit_local<T: MutVisitor>(local: &mut P<Local>, vis: &mut T) {
fn walk_local<T: MutVisitor>(local: &mut P<Local>, vis: &mut T) {
let Local { id, pat, ty, kind, span, colon_sp, attrs, tokens } = local.deref_mut();
vis.visit_id(id);
visit_attrs(attrs, vis);
@ -642,7 +636,7 @@ fn noop_visit_local<T: MutVisitor>(local: &mut P<Local>, vis: &mut T) {
vis.visit_span(span);
}
fn noop_visit_attribute<T: MutVisitor>(attr: &mut Attribute, vis: &mut T) {
fn walk_attribute<T: MutVisitor>(attr: &mut Attribute, vis: &mut T) {
let Attribute { kind, id: _, style: _, span } = attr;
match kind {
AttrKind::Normal(normal) => {
@ -660,25 +654,25 @@ fn noop_visit_attribute<T: MutVisitor>(attr: &mut Attribute, vis: &mut T) {
vis.visit_span(span);
}
fn noop_visit_mac<T: MutVisitor>(mac: &mut MacCall, vis: &mut T) {
fn walk_mac<T: MutVisitor>(mac: &mut MacCall, vis: &mut T) {
let MacCall { path, args } = mac;
vis.visit_path(path);
visit_delim_args(args, vis);
}
fn noop_visit_macro_def<T: MutVisitor>(macro_def: &mut MacroDef, vis: &mut T) {
fn walk_macro_def<T: MutVisitor>(macro_def: &mut MacroDef, vis: &mut T) {
let MacroDef { body, macro_rules: _ } = macro_def;
visit_delim_args(body, vis);
}
fn noop_visit_meta_list_item<T: MutVisitor>(li: &mut NestedMetaItem, vis: &mut T) {
fn walk_meta_list_item<T: MutVisitor>(li: &mut NestedMetaItem, vis: &mut T) {
match li {
NestedMetaItem::MetaItem(mi) => vis.visit_meta_item(mi),
NestedMetaItem::Lit(_lit) => {}
}
}
fn noop_visit_meta_item<T: MutVisitor>(mi: &mut MetaItem, vis: &mut T) {
fn walk_meta_item<T: MutVisitor>(mi: &mut MetaItem, vis: &mut T) {
let MetaItem { unsafety: _, path: _, kind, span } = mi;
match kind {
MetaItemKind::Word => {}
@ -688,7 +682,7 @@ fn noop_visit_meta_item<T: MutVisitor>(mi: &mut MetaItem, vis: &mut T) {
vis.visit_span(span);
}
pub fn noop_flat_map_param<T: MutVisitor>(mut param: Param, vis: &mut T) -> SmallVec<[Param; 1]> {
pub fn walk_flat_map_param<T: MutVisitor>(mut param: Param, vis: &mut T) -> SmallVec<[Param; 1]> {
let Param { attrs, id, pat, span, ty, is_placeholder: _ } = &mut param;
vis.visit_id(id);
visit_attrs(attrs, vis);
@ -873,7 +867,7 @@ fn visit_constness<T: MutVisitor>(constness: &mut Const, vis: &mut T) {
}
}
fn noop_visit_closure_binder<T: MutVisitor>(binder: &mut ClosureBinder, vis: &mut T) {
fn walk_closure_binder<T: MutVisitor>(binder: &mut ClosureBinder, vis: &mut T) {
match binder {
ClosureBinder::NotPresent => {}
ClosureBinder::For { span: _, generic_params } => {
@ -882,7 +876,7 @@ fn noop_visit_closure_binder<T: MutVisitor>(binder: &mut ClosureBinder, vis: &mu
}
}
fn noop_visit_coroutine_kind<T: MutVisitor>(coroutine_kind: &mut CoroutineKind, vis: &mut T) {
fn walk_coroutine_kind<T: MutVisitor>(coroutine_kind: &mut CoroutineKind, vis: &mut T) {
match coroutine_kind {
CoroutineKind::Async { span, closure_id, return_impl_trait_id }
| CoroutineKind::Gen { span, closure_id, return_impl_trait_id }
@ -894,7 +888,7 @@ fn noop_visit_coroutine_kind<T: MutVisitor>(coroutine_kind: &mut CoroutineKind,
}
}
fn noop_visit_fn<T: MutVisitor>(kind: FnKind<'_>, vis: &mut T) {
fn walk_fn<T: MutVisitor>(kind: FnKind<'_>, vis: &mut T) {
match kind {
FnKind::Fn(_ctxt, _ident, FnSig { header, decl, span }, generics, body) => {
// Identifier and visibility are visited as a part of the item.
@ -914,23 +908,23 @@ fn noop_visit_fn<T: MutVisitor>(kind: FnKind<'_>, vis: &mut T) {
}
}
fn noop_visit_fn_decl<T: MutVisitor>(decl: &mut P<FnDecl>, vis: &mut T) {
fn walk_fn_decl<T: MutVisitor>(decl: &mut P<FnDecl>, vis: &mut T) {
let FnDecl { inputs, output } = decl.deref_mut();
inputs.flat_map_in_place(|param| vis.flat_map_param(param));
noop_visit_fn_ret_ty(output, vis);
walk_fn_ret_ty(output, vis);
}
fn noop_visit_fn_ret_ty<T: MutVisitor>(fn_ret_ty: &mut FnRetTy, vis: &mut T) {
fn walk_fn_ret_ty<T: MutVisitor>(fn_ret_ty: &mut FnRetTy, vis: &mut T) {
match fn_ret_ty {
FnRetTy::Default(span) => vis.visit_span(span),
FnRetTy::Ty(ty) => vis.visit_ty(ty),
}
}
fn noop_visit_param_bound<T: MutVisitor>(pb: &mut GenericBound, vis: &mut T) {
fn walk_param_bound<T: MutVisitor>(pb: &mut GenericBound, vis: &mut T) {
match pb {
GenericBound::Trait(ty, _modifier) => vis.visit_poly_trait_ref(ty),
GenericBound::Outlives(lifetime) => noop_visit_lifetime(lifetime, vis),
GenericBound::Outlives(lifetime) => walk_lifetime(lifetime, vis),
GenericBound::Use(args, span) => {
for arg in args {
vis.visit_precise_capturing_arg(arg);
@ -940,7 +934,7 @@ fn noop_visit_param_bound<T: MutVisitor>(pb: &mut GenericBound, vis: &mut T) {
}
}
fn noop_visit_precise_capturing_arg<T: MutVisitor>(arg: &mut PreciseCapturingArg, vis: &mut T) {
fn walk_precise_capturing_arg<T: MutVisitor>(arg: &mut PreciseCapturingArg, vis: &mut T) {
match arg {
PreciseCapturingArg::Lifetime(lt) => {
vis.visit_lifetime(lt);
@ -952,7 +946,7 @@ fn noop_visit_precise_capturing_arg<T: MutVisitor>(arg: &mut PreciseCapturingArg
}
}
pub fn noop_flat_map_generic_param<T: MutVisitor>(
pub fn walk_flat_map_generic_param<T: MutVisitor>(
mut param: GenericParam,
vis: &mut T,
) -> SmallVec<[GenericParam; 1]> {
@ -977,23 +971,23 @@ pub fn noop_flat_map_generic_param<T: MutVisitor>(
smallvec![param]
}
fn noop_visit_label<T: MutVisitor>(Label { ident }: &mut Label, vis: &mut T) {
fn walk_label<T: MutVisitor>(Label { ident }: &mut Label, vis: &mut T) {
vis.visit_ident(ident);
}
fn noop_visit_lifetime<T: MutVisitor>(Lifetime { id, ident }: &mut Lifetime, vis: &mut T) {
fn walk_lifetime<T: MutVisitor>(Lifetime { id, ident }: &mut Lifetime, vis: &mut T) {
vis.visit_id(id);
vis.visit_ident(ident);
}
fn noop_visit_generics<T: MutVisitor>(generics: &mut Generics, vis: &mut T) {
fn walk_generics<T: MutVisitor>(generics: &mut Generics, vis: &mut T) {
let Generics { params, where_clause, span } = generics;
params.flat_map_in_place(|param| vis.flat_map_generic_param(param));
vis.visit_where_clause(where_clause);
vis.visit_span(span);
}
fn noop_visit_ty_alias_where_clauses<T: MutVisitor>(tawcs: &mut TyAliasWhereClauses, vis: &mut T) {
fn walk_ty_alias_where_clauses<T: MutVisitor>(tawcs: &mut TyAliasWhereClauses, vis: &mut T) {
let TyAliasWhereClauses { before, after, split: _ } = tawcs;
let TyAliasWhereClause { has_where_token: _, span: span_before } = before;
let TyAliasWhereClause { has_where_token: _, span: span_after } = after;
@ -1001,13 +995,13 @@ fn noop_visit_ty_alias_where_clauses<T: MutVisitor>(tawcs: &mut TyAliasWhereClau
vis.visit_span(span_after);
}
fn noop_visit_where_clause<T: MutVisitor>(wc: &mut WhereClause, vis: &mut T) {
fn walk_where_clause<T: MutVisitor>(wc: &mut WhereClause, vis: &mut T) {
let WhereClause { has_where_token: _, predicates, span } = wc;
visit_thin_vec(predicates, |predicate| vis.visit_where_predicate(predicate));
vis.visit_span(span);
}
fn noop_visit_where_predicate<T: MutVisitor>(pred: &mut WherePredicate, vis: &mut T) {
fn walk_where_predicate<T: MutVisitor>(pred: &mut WherePredicate, vis: &mut T) {
match pred {
WherePredicate::BoundPredicate(bp) => {
let WhereBoundPredicate { span, bound_generic_params, bounded_ty, bounds } = bp;
@ -1031,7 +1025,7 @@ fn noop_visit_where_predicate<T: MutVisitor>(pred: &mut WherePredicate, vis: &mu
}
}
fn noop_visit_variant_data<T: MutVisitor>(vdata: &mut VariantData, vis: &mut T) {
fn walk_variant_data<T: MutVisitor>(vdata: &mut VariantData, vis: &mut T) {
match vdata {
VariantData::Struct { fields, recovered: _ } => {
fields.flat_map_in_place(|field| vis.flat_map_field_def(field));
@ -1044,19 +1038,19 @@ fn noop_visit_variant_data<T: MutVisitor>(vdata: &mut VariantData, vis: &mut T)
}
}
fn noop_visit_trait_ref<T: MutVisitor>(TraitRef { path, ref_id }: &mut TraitRef, vis: &mut T) {
fn walk_trait_ref<T: MutVisitor>(TraitRef { path, ref_id }: &mut TraitRef, vis: &mut T) {
vis.visit_id(ref_id);
vis.visit_path(path);
}
fn noop_visit_poly_trait_ref<T: MutVisitor>(p: &mut PolyTraitRef, vis: &mut T) {
fn walk_poly_trait_ref<T: MutVisitor>(p: &mut PolyTraitRef, vis: &mut T) {
let PolyTraitRef { bound_generic_params, trait_ref, span } = p;
bound_generic_params.flat_map_in_place(|param| vis.flat_map_generic_param(param));
vis.visit_trait_ref(trait_ref);
vis.visit_span(span);
}
pub fn noop_flat_map_field_def<T: MutVisitor>(
pub fn walk_flat_map_field_def<T: MutVisitor>(
mut fd: FieldDef,
visitor: &mut T,
) -> SmallVec<[FieldDef; 1]> {
@ -1070,7 +1064,7 @@ pub fn noop_flat_map_field_def<T: MutVisitor>(
smallvec![fd]
}
pub fn noop_flat_map_expr_field<T: MutVisitor>(
pub fn walk_flat_map_expr_field<T: MutVisitor>(
mut f: ExprField,
vis: &mut T,
) -> SmallVec<[ExprField; 1]> {
@ -1083,11 +1077,11 @@ pub fn noop_flat_map_expr_field<T: MutVisitor>(
smallvec![f]
}
fn noop_visit_mt<T: MutVisitor>(MutTy { ty, mutbl: _ }: &mut MutTy, vis: &mut T) {
fn walk_mt<T: MutVisitor>(MutTy { ty, mutbl: _ }: &mut MutTy, vis: &mut T) {
vis.visit_ty(ty);
}
pub fn noop_visit_block<T: MutVisitor>(block: &mut P<Block>, vis: &mut T) {
pub fn walk_block<T: MutVisitor>(block: &mut P<Block>, vis: &mut T) {
let Block { id, stmts, rules: _, span, tokens, could_be_bare_literal: _ } = block.deref_mut();
vis.visit_id(id);
stmts.flat_map_in_place(|stmt| vis.flat_map_stmt(stmt));
@ -1095,18 +1089,18 @@ pub fn noop_visit_block<T: MutVisitor>(block: &mut P<Block>, vis: &mut T) {
vis.visit_span(span);
}
pub fn noop_visit_item_kind(
pub fn walk_item_kind(
kind: &mut impl NoopVisitItemKind,
ident: Ident,
span: Span,
id: NodeId,
vis: &mut impl MutVisitor,
) {
kind.noop_visit(None, ident, span, id, vis)
kind.walk(None, ident, span, id, vis)
}
impl NoopVisitItemKind for ItemKind {
fn noop_visit(
fn walk(
&mut self,
ctxt: Option<AssocCtxt>,
ident: Ident,
@ -1147,7 +1141,7 @@ impl NoopVisitItemKind for ItemKind {
vis.visit_generics(generics);
visit_bounds(bounds, BoundKind::Bound, vis);
visit_opt(ty, |ty| vis.visit_ty(ty));
noop_visit_ty_alias_where_clauses(where_clauses, vis);
walk_ty_alias_where_clauses(where_clauses, vis);
}
ItemKind::Enum(EnumDef { variants }, generics) => {
vis.visit_generics(generics);
@ -1226,7 +1220,7 @@ impl NoopVisitItemKind for ItemKind {
}
impl NoopVisitItemKind for AssocItemKind {
fn noop_visit(
fn walk(
&mut self,
ctxt: Option<AssocCtxt>,
ident: Ident,
@ -1258,7 +1252,7 @@ impl NoopVisitItemKind for AssocItemKind {
visitor.visit_generics(generics);
visit_bounds(bounds, BoundKind::Bound, visitor);
visit_opt(ty, |ty| visitor.visit_ty(ty));
noop_visit_ty_alias_where_clauses(where_clauses, visitor);
walk_ty_alias_where_clauses(where_clauses, visitor);
}
AssocItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
AssocItemKind::Delegation(box Delegation {
@ -1308,14 +1302,14 @@ fn visit_const_item<T: MutVisitor>(
visit_opt(expr, |expr| visitor.visit_expr(expr));
}
fn noop_visit_fn_header<T: MutVisitor>(header: &mut FnHeader, vis: &mut T) {
fn walk_fn_header<T: MutVisitor>(header: &mut FnHeader, vis: &mut T) {
let FnHeader { safety, coroutine_kind, constness, ext: _ } = header;
visit_constness(constness, vis);
coroutine_kind.as_mut().map(|coroutine_kind| vis.visit_coroutine_kind(coroutine_kind));
visit_safety(safety, vis);
}
pub fn noop_visit_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
pub fn walk_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
let Crate { attrs, items, spans, id, is_placeholder: _ } = krate;
vis.visit_id(id);
visit_attrs(attrs, vis);
@ -1326,7 +1320,7 @@ pub fn noop_visit_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
}
/// Mutates one item, returning the item again.
pub fn noop_flat_map_item<K: NoopVisitItemKind>(
pub fn walk_flat_map_item<K: NoopVisitItemKind>(
mut item: P<Item<K>>,
ctxt: Option<AssocCtxt>,
visitor: &mut impl MutVisitor,
@ -1336,14 +1330,14 @@ pub fn noop_flat_map_item<K: NoopVisitItemKind>(
visit_attrs(attrs, visitor);
visitor.visit_vis(vis);
visitor.visit_ident(ident);
kind.noop_visit(ctxt, *ident, *span, *id, visitor);
kind.walk(ctxt, *ident, *span, *id, visitor);
visit_lazy_tts(tokens, visitor);
visitor.visit_span(span);
smallvec![item]
}
impl NoopVisitItemKind for ForeignItemKind {
fn noop_visit(
fn walk(
&mut self,
ctxt: Option<AssocCtxt>,
ident: Ident,
@ -1372,14 +1366,14 @@ impl NoopVisitItemKind for ForeignItemKind {
visitor.visit_generics(generics);
visit_bounds(bounds, BoundKind::Bound, visitor);
visit_opt(ty, |ty| visitor.visit_ty(ty));
noop_visit_ty_alias_where_clauses(where_clauses, visitor);
walk_ty_alias_where_clauses(where_clauses, visitor);
}
ForeignItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
}
}
}
pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
pub fn walk_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
let Pat { id, kind, span, tokens } = pat.deref_mut();
vis.visit_id(id);
match kind {
@ -1422,12 +1416,12 @@ pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
vis.visit_span(span);
}
fn noop_visit_anon_const<T: MutVisitor>(AnonConst { id, value }: &mut AnonConst, vis: &mut T) {
fn walk_anon_const<T: MutVisitor>(AnonConst { id, value }: &mut AnonConst, vis: &mut T) {
vis.visit_id(id);
vis.visit_expr(value);
}
fn noop_visit_inline_asm<T: MutVisitor>(asm: &mut InlineAsm, vis: &mut T) {
fn walk_inline_asm<T: MutVisitor>(asm: &mut InlineAsm, vis: &mut T) {
// FIXME: Visit spans inside all this currently ignored stuff.
let InlineAsm {
template: _,
@ -1457,7 +1451,7 @@ fn noop_visit_inline_asm<T: MutVisitor>(asm: &mut InlineAsm, vis: &mut T) {
}
}
fn noop_visit_inline_asm_sym<T: MutVisitor>(
fn walk_inline_asm_sym<T: MutVisitor>(
InlineAsmSym { id, qself, path }: &mut InlineAsmSym,
vis: &mut T,
) {
@ -1466,7 +1460,7 @@ fn noop_visit_inline_asm_sym<T: MutVisitor>(
vis.visit_path(path);
}
fn noop_visit_format_args<T: MutVisitor>(fmt: &mut FormatArgs, vis: &mut T) {
fn walk_format_args<T: MutVisitor>(fmt: &mut FormatArgs, vis: &mut T) {
// FIXME: visit the template exhaustively.
let FormatArgs { span, template: _, arguments } = fmt;
for FormatArgument { kind, expr } in arguments.all_args_mut() {
@ -1481,10 +1475,7 @@ fn noop_visit_format_args<T: MutVisitor>(fmt: &mut FormatArgs, vis: &mut T) {
vis.visit_span(span);
}
pub fn noop_visit_expr<T: MutVisitor>(
Expr { kind, id, span, attrs, tokens }: &mut Expr,
vis: &mut T,
) {
pub fn walk_expr<T: MutVisitor>(Expr { kind, id, span, attrs, tokens }: &mut Expr, vis: &mut T) {
vis.visit_id(id);
visit_attrs(attrs, vis);
match kind {
@ -1673,12 +1664,12 @@ pub fn noop_filter_map_expr<T: MutVisitor>(mut e: P<Expr>, vis: &mut T) -> Optio
})
}
pub fn noop_flat_map_stmt<T: MutVisitor>(
pub fn walk_flat_map_stmt<T: MutVisitor>(
Stmt { kind, mut span, mut id }: Stmt,
vis: &mut T,
) -> SmallVec<[Stmt; 1]> {
vis.visit_id(&mut id);
let stmts: SmallVec<_> = noop_flat_map_stmt_kind(kind, vis)
let stmts: SmallVec<_> = walk_flat_map_stmt_kind(kind, vis)
.into_iter()
.map(|kind| Stmt { id, kind, span })
.collect();
@ -1692,7 +1683,7 @@ pub fn noop_flat_map_stmt<T: MutVisitor>(
stmts
}
fn noop_flat_map_stmt_kind<T: MutVisitor>(kind: StmtKind, vis: &mut T) -> SmallVec<[StmtKind; 1]> {
fn walk_flat_map_stmt_kind<T: MutVisitor>(kind: StmtKind, vis: &mut T) -> SmallVec<[StmtKind; 1]> {
match kind {
StmtKind::Let(mut local) => smallvec![StmtKind::Let({
vis.visit_local(&mut local);
@ -1712,7 +1703,7 @@ fn noop_flat_map_stmt_kind<T: MutVisitor>(kind: StmtKind, vis: &mut T) -> SmallV
}
}
fn noop_visit_vis<T: MutVisitor>(visibility: &mut Visibility, vis: &mut T) {
fn walk_vis<T: MutVisitor>(visibility: &mut Visibility, vis: &mut T) {
let Visibility { kind, span, tokens } = visibility;
match kind {
VisibilityKind::Public | VisibilityKind::Inherited => {}
@ -1725,7 +1716,7 @@ fn noop_visit_vis<T: MutVisitor>(visibility: &mut Visibility, vis: &mut T) {
vis.visit_span(span);
}
fn noop_visit_capture_by<T: MutVisitor>(capture_by: &mut CaptureBy, vis: &mut T) {
fn walk_capture_by<T: MutVisitor>(capture_by: &mut CaptureBy, vis: &mut T) {
match capture_by {
CaptureBy::Ref => {}
CaptureBy::Value { move_kw } => {

View File

@ -212,18 +212,18 @@ impl MutVisitor for CfgEval<'_> {
#[instrument(level = "trace", skip(self))]
fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
self.0.configure_expr(expr, false);
mut_visit::noop_visit_expr(expr, self);
mut_visit::walk_expr(expr, self);
}
#[instrument(level = "trace", skip(self))]
fn visit_method_receiver_expr(&mut self, expr: &mut P<ast::Expr>) {
self.0.configure_expr(expr, true);
mut_visit::noop_visit_expr(expr, self);
mut_visit::walk_expr(expr, self);
}
fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
let mut expr = configure!(self, expr);
mut_visit::noop_visit_expr(&mut expr, self);
mut_visit::walk_expr(&mut expr, self);
Some(expr)
}
@ -231,15 +231,15 @@ impl MutVisitor for CfgEval<'_> {
&mut self,
param: ast::GenericParam,
) -> SmallVec<[ast::GenericParam; 1]> {
mut_visit::noop_flat_map_generic_param(configure!(self, param), self)
mut_visit::walk_flat_map_generic_param(configure!(self, param), self)
}
fn flat_map_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
mut_visit::noop_flat_map_stmt(configure!(self, stmt), self)
mut_visit::walk_flat_map_stmt(configure!(self, stmt), self)
}
fn flat_map_item(&mut self, item: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> {
mut_visit::noop_flat_map_item(configure!(self, item), None, self)
mut_visit::walk_flat_map_item(configure!(self, item), None, self)
}
fn flat_map_assoc_item(
@ -247,37 +247,37 @@ impl MutVisitor for CfgEval<'_> {
item: P<ast::AssocItem>,
ctxt: AssocCtxt,
) -> SmallVec<[P<ast::AssocItem>; 1]> {
mut_visit::noop_flat_map_item(configure!(self, item), Some(ctxt), self)
mut_visit::walk_flat_map_item(configure!(self, item), Some(ctxt), self)
}
fn flat_map_foreign_item(
&mut self,
foreign_item: P<ast::ForeignItem>,
) -> SmallVec<[P<ast::ForeignItem>; 1]> {
mut_visit::noop_flat_map_item(configure!(self, foreign_item), None, self)
mut_visit::walk_flat_map_item(configure!(self, foreign_item), None, self)
}
fn flat_map_arm(&mut self, arm: ast::Arm) -> SmallVec<[ast::Arm; 1]> {
mut_visit::noop_flat_map_arm(configure!(self, arm), self)
mut_visit::walk_flat_map_arm(configure!(self, arm), self)
}
fn flat_map_expr_field(&mut self, field: ast::ExprField) -> SmallVec<[ast::ExprField; 1]> {
mut_visit::noop_flat_map_expr_field(configure!(self, field), self)
mut_visit::walk_flat_map_expr_field(configure!(self, field), self)
}
fn flat_map_pat_field(&mut self, fp: ast::PatField) -> SmallVec<[ast::PatField; 1]> {
mut_visit::noop_flat_map_pat_field(configure!(self, fp), self)
mut_visit::walk_flat_map_pat_field(configure!(self, fp), self)
}
fn flat_map_param(&mut self, p: ast::Param) -> SmallVec<[ast::Param; 1]> {
mut_visit::noop_flat_map_param(configure!(self, p), self)
mut_visit::walk_flat_map_param(configure!(self, p), self)
}
fn flat_map_field_def(&mut self, sf: ast::FieldDef) -> SmallVec<[ast::FieldDef; 1]> {
mut_visit::noop_flat_map_field_def(configure!(self, sf), self)
mut_visit::walk_flat_map_field_def(configure!(self, sf), self)
}
fn flat_map_variant(&mut self, variant: ast::Variant) -> SmallVec<[ast::Variant; 1]> {
mut_visit::noop_flat_map_variant(configure!(self, variant), self)
mut_visit::walk_flat_map_variant(configure!(self, variant), self)
}
}

View File

@ -122,7 +122,7 @@ impl TestHarnessGenerator<'_> {
impl<'a> MutVisitor for TestHarnessGenerator<'a> {
fn visit_crate(&mut self, c: &mut ast::Crate) {
let prev_tests = mem::take(&mut self.tests);
noop_visit_crate(c, self);
walk_crate(c, self);
self.add_test_cases(ast::CRATE_NODE_ID, c.spans.inner_span, prev_tests);
// Create a main function to run our tests
@ -144,7 +144,7 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
item.kind
{
let prev_tests = mem::take(&mut self.tests);
noop_visit_item_kind(&mut item.kind, item.ident, item.span, item.id, self);
walk_item_kind(&mut item.kind, item.ident, item.span, item.id, self);
self.add_test_cases(item.id, span, prev_tests);
} else {
// But in those cases, we emit a lint to warn the user of these missing tests.
@ -192,7 +192,7 @@ struct EntryPointCleaner<'a> {
impl<'a> MutVisitor for EntryPointCleaner<'a> {
fn flat_map_item(&mut self, i: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> {
self.depth += 1;
let item = noop_flat_map_item(i, None, self).expect_one("noop did something");
let item = walk_flat_map_item(i, None, self).expect_one("noop did something");
self.depth -= 1;
// Remove any #[rustc_main] or #[start] from the AST so it doesn't

View File

@ -1036,7 +1036,7 @@ pub(crate) fn ensure_complete_parse<'a>(
}
}
/// Wraps a call to `noop_visit_*` / `noop_flat_map_*`
/// Wraps a call to `walk_*` / `walk_flat_map_*`
/// for an AST node that supports attributes
/// (see the `Annotatable` enum)
/// This method assigns a `NodeId`, and sets that `NodeId`
@ -1056,7 +1056,7 @@ pub(crate) fn ensure_complete_parse<'a>(
/// * `id` is a mutable reference to the `NodeId` field
/// of the current AST node.
/// * `closure` is a closure that executes the
/// `noop_visit_*` / `noop_flat_map_*` method
/// `walk_*` / `walk_flat_map_*` method
/// for the current AST node.
macro_rules! assign_id {
($self:ident, $id:expr, $closure:expr) => {{
@ -1090,10 +1090,10 @@ trait InvocationCollectorNode: HasAttrs + HasNodeId + Sized {
fn descr() -> &'static str {
unreachable!()
}
fn noop_flat_map<V: MutVisitor>(self, _visitor: &mut V) -> Self::OutputTy {
fn walk_flat_map<V: MutVisitor>(self, _visitor: &mut V) -> Self::OutputTy {
unreachable!()
}
fn noop_visit<V: MutVisitor>(&mut self, _visitor: &mut V) {
fn walk<V: MutVisitor>(&mut self, _visitor: &mut V) {
unreachable!()
}
fn is_mac_call(&self) -> bool {
@ -1117,12 +1117,12 @@ trait InvocationCollectorNode: HasAttrs + HasNodeId + Sized {
fn pre_flat_map_node_collect_attr(_cfg: &StripUnconfigured<'_>, _attr: &ast::Attribute) {}
fn post_flat_map_node_collect_bang(_output: &mut Self::OutputTy, _add_semicolon: AddSemicolon) {
}
fn wrap_flat_map_node_noop_flat_map(
fn wrap_flat_map_node_walk_flat_map(
node: Self,
collector: &mut InvocationCollector<'_, '_>,
noop_flat_map: impl FnOnce(Self, &mut InvocationCollector<'_, '_>) -> Self::OutputTy,
walk_flat_map: impl FnOnce(Self, &mut InvocationCollector<'_, '_>) -> Self::OutputTy,
) -> Result<Self::OutputTy, Self> {
Ok(noop_flat_map(node, collector))
Ok(walk_flat_map(node, collector))
}
fn expand_cfg_false(
&mut self,
@ -1148,8 +1148,8 @@ impl InvocationCollectorNode for P<ast::Item> {
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_items()
}
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
noop_flat_map_item(self, None, visitor)
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
walk_flat_map_item(self, None, visitor)
}
fn is_mac_call(&self) -> bool {
matches!(self.kind, ItemKind::MacCall(..))
@ -1176,13 +1176,13 @@ impl InvocationCollectorNode for P<ast::Item> {
fn flatten_outputs(items: impl Iterator<Item = Self::OutputTy>) -> Self::OutputTy {
items.flatten().collect()
}
fn wrap_flat_map_node_noop_flat_map(
fn wrap_flat_map_node_walk_flat_map(
mut node: Self,
collector: &mut InvocationCollector<'_, '_>,
noop_flat_map: impl FnOnce(Self, &mut InvocationCollector<'_, '_>) -> Self::OutputTy,
walk_flat_map: impl FnOnce(Self, &mut InvocationCollector<'_, '_>) -> Self::OutputTy,
) -> Result<Self::OutputTy, Self> {
if !matches!(node.kind, ItemKind::Mod(..)) {
return Ok(noop_flat_map(node, collector));
return Ok(walk_flat_map(node, collector));
}
// Work around borrow checker not seeing through `P`'s deref.
@ -1252,7 +1252,7 @@ impl InvocationCollectorNode for P<ast::Item> {
let orig_dir_ownership =
mem::replace(&mut ecx.current_expansion.dir_ownership, dir_ownership);
let res = Ok(noop_flat_map(node, collector));
let res = Ok(walk_flat_map(node, collector));
collector.cx.current_expansion.dir_ownership = orig_dir_ownership;
collector.cx.current_expansion.module = orig_module;
@ -1292,8 +1292,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, TraitItemTag>
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_trait_items()
}
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
noop_flat_map_item(self.wrapped, Some(AssocCtxt::Trait), visitor)
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
walk_flat_map_item(self.wrapped, Some(AssocCtxt::Trait), visitor)
}
fn is_mac_call(&self) -> bool {
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
@ -1333,8 +1333,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, ImplItemTag>
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_impl_items()
}
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
noop_flat_map_item(self.wrapped, Some(AssocCtxt::Impl), visitor)
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
walk_flat_map_item(self.wrapped, Some(AssocCtxt::Impl), visitor)
}
fn is_mac_call(&self) -> bool {
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
@ -1371,8 +1371,8 @@ impl InvocationCollectorNode for P<ast::ForeignItem> {
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_foreign_items()
}
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
noop_flat_map_item(self, None, visitor)
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
walk_flat_map_item(self, None, visitor)
}
fn is_mac_call(&self) -> bool {
matches!(self.kind, ForeignItemKind::MacCall(..))
@ -1394,8 +1394,8 @@ impl InvocationCollectorNode for ast::Variant {
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_variants()
}
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
noop_flat_map_variant(self, visitor)
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
walk_flat_map_variant(self, visitor)
}
}
@ -1407,8 +1407,8 @@ impl InvocationCollectorNode for ast::FieldDef {
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_field_defs()
}
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
noop_flat_map_field_def(self, visitor)
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
walk_flat_map_field_def(self, visitor)
}
}
@ -1420,8 +1420,8 @@ impl InvocationCollectorNode for ast::PatField {
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_pat_fields()
}
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
noop_flat_map_pat_field(self, visitor)
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
walk_flat_map_pat_field(self, visitor)
}
}
@ -1433,8 +1433,8 @@ impl InvocationCollectorNode for ast::ExprField {
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_expr_fields()
}
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
noop_flat_map_expr_field(self, visitor)
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
walk_flat_map_expr_field(self, visitor)
}
}
@ -1446,8 +1446,8 @@ impl InvocationCollectorNode for ast::Param {
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_params()
}
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
noop_flat_map_param(self, visitor)
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
walk_flat_map_param(self, visitor)
}
}
@ -1459,8 +1459,8 @@ impl InvocationCollectorNode for ast::GenericParam {
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_generic_params()
}
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
noop_flat_map_generic_param(self, visitor)
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
walk_flat_map_generic_param(self, visitor)
}
}
@ -1472,8 +1472,8 @@ impl InvocationCollectorNode for ast::Arm {
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_arms()
}
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
noop_flat_map_arm(self, visitor)
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
walk_flat_map_arm(self, visitor)
}
}
@ -1486,8 +1486,8 @@ impl InvocationCollectorNode for ast::Stmt {
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_stmts()
}
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
noop_flat_map_stmt(self, visitor)
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
walk_flat_map_stmt(self, visitor)
}
fn is_mac_call(&self) -> bool {
match &self.kind {
@ -1560,8 +1560,8 @@ impl InvocationCollectorNode for ast::Crate {
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_crate()
}
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
noop_visit_crate(self, visitor)
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
walk_crate(self, visitor)
}
fn expand_cfg_false(
&mut self,
@ -1586,8 +1586,8 @@ impl InvocationCollectorNode for P<ast::Ty> {
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_ty()
}
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
noop_visit_ty(self, visitor)
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
walk_ty(self, visitor)
}
fn is_mac_call(&self) -> bool {
matches!(self.kind, ast::TyKind::MacCall(..))
@ -1610,8 +1610,8 @@ impl InvocationCollectorNode for P<ast::Pat> {
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_pat()
}
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
noop_visit_pat(self, visitor)
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
walk_pat(self, visitor)
}
fn is_mac_call(&self) -> bool {
matches!(self.kind, PatKind::MacCall(..))
@ -1638,8 +1638,8 @@ impl InvocationCollectorNode for P<ast::Expr> {
fn descr() -> &'static str {
"an expression"
}
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
noop_visit_expr(self, visitor)
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
walk_expr(self, visitor)
}
fn is_mac_call(&self) -> bool {
matches!(self.kind, ExprKind::MacCall(..))
@ -1664,8 +1664,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::Expr>, OptExprTag> {
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_opt_expr()
}
fn noop_flat_map<V: MutVisitor>(mut self, visitor: &mut V) -> Self::OutputTy {
noop_visit_expr(&mut self.wrapped, visitor);
fn walk_flat_map<V: MutVisitor>(mut self, visitor: &mut V) -> Self::OutputTy {
walk_expr(&mut self.wrapped, visitor);
Some(self.wrapped)
}
fn is_mac_call(&self) -> bool {
@ -1704,8 +1704,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::Expr>, MethodReceiverTag>
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
AstNodeWrapper::new(fragment.make_method_receiver_expr(), MethodReceiverTag)
}
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
noop_visit_expr(&mut self.wrapped, visitor)
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
walk_expr(&mut self.wrapped, visitor)
}
fn is_mac_call(&self) -> bool {
matches!(self.wrapped.kind, ast::ExprKind::MacCall(..))
@ -2015,12 +2015,12 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
);
Node::flatten_outputs(single_delegations.map(|item| {
let mut item = Node::from_item(item);
assign_id!(self, item.node_id_mut(), || item.noop_flat_map(self))
assign_id!(self, item.node_id_mut(), || item.walk_flat_map(self))
}))
}
None => {
match Node::wrap_flat_map_node_noop_flat_map(node, self, |mut node, this| {
assign_id!(this, node.node_id_mut(), || node.noop_flat_map(this))
match Node::wrap_flat_map_node_walk_flat_map(node, self, |mut node, this| {
assign_id!(this, node.node_id_mut(), || node.walk_flat_map(this))
}) {
Ok(output) => output,
Err(returned_node) => {
@ -2068,7 +2068,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
}
None if node.delegation().is_some() => unreachable!(),
None => {
assign_id!(self, node.node_id_mut(), || node.noop_visit(self))
assign_id!(self, node.node_id_mut(), || node.walk(self))
}
};
}
@ -2147,11 +2147,11 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
self.cx.current_expansion.is_trailing_mac = true;
// Don't use `assign_id` for this statement - it may get removed
// entirely due to a `#[cfg]` on the contained expression
let res = noop_flat_map_stmt(node, self);
let res = walk_flat_map_stmt(node, self);
self.cx.current_expansion.is_trailing_mac = false;
res
}
_ => noop_flat_map_stmt(node, self),
_ => walk_flat_map_stmt(node, self),
};
}
@ -2195,7 +2195,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
&mut self.cx.current_expansion.dir_ownership,
DirOwnership::UnownedViaBlock,
);
noop_visit_block(node, self);
walk_block(node, self);
self.cx.current_expansion.dir_ownership = orig_dir_ownership;
}

View File

@ -209,7 +209,7 @@ impl MutVisitor for PlaceholderExpander {
if arm.is_placeholder {
self.remove(arm.id).make_arms()
} else {
noop_flat_map_arm(arm, self)
walk_flat_map_arm(arm, self)
}
}
@ -217,7 +217,7 @@ impl MutVisitor for PlaceholderExpander {
if field.is_placeholder {
self.remove(field.id).make_expr_fields()
} else {
noop_flat_map_expr_field(field, self)
walk_flat_map_expr_field(field, self)
}
}
@ -225,7 +225,7 @@ impl MutVisitor for PlaceholderExpander {
if fp.is_placeholder {
self.remove(fp.id).make_pat_fields()
} else {
noop_flat_map_pat_field(fp, self)
walk_flat_map_pat_field(fp, self)
}
}
@ -236,7 +236,7 @@ impl MutVisitor for PlaceholderExpander {
if param.is_placeholder {
self.remove(param.id).make_generic_params()
} else {
noop_flat_map_generic_param(param, self)
walk_flat_map_generic_param(param, self)
}
}
@ -244,7 +244,7 @@ impl MutVisitor for PlaceholderExpander {
if p.is_placeholder {
self.remove(p.id).make_params()
} else {
noop_flat_map_param(p, self)
walk_flat_map_param(p, self)
}
}
@ -252,7 +252,7 @@ impl MutVisitor for PlaceholderExpander {
if sf.is_placeholder {
self.remove(sf.id).make_field_defs()
} else {
noop_flat_map_field_def(sf, self)
walk_flat_map_field_def(sf, self)
}
}
@ -260,14 +260,14 @@ impl MutVisitor for PlaceholderExpander {
if variant.is_placeholder {
self.remove(variant.id).make_variants()
} else {
noop_flat_map_variant(variant, self)
walk_flat_map_variant(variant, self)
}
}
fn flat_map_item(&mut self, item: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> {
match item.kind {
ast::ItemKind::MacCall(_) => self.remove(item.id).make_items(),
_ => noop_flat_map_item(item, None, self),
_ => walk_flat_map_item(item, None, self),
}
}
@ -284,7 +284,7 @@ impl MutVisitor for PlaceholderExpander {
AssocCtxt::Impl => it.make_impl_items(),
}
}
_ => noop_flat_map_item(item, Some(ctxt), self),
_ => walk_flat_map_item(item, Some(ctxt), self),
}
}
@ -294,21 +294,21 @@ impl MutVisitor for PlaceholderExpander {
) -> SmallVec<[P<ast::ForeignItem>; 1]> {
match item.kind {
ast::ForeignItemKind::MacCall(_) => self.remove(item.id).make_foreign_items(),
_ => noop_flat_map_item(item, None, self),
_ => walk_flat_map_item(item, None, self),
}
}
fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
match expr.kind {
ast::ExprKind::MacCall(_) => *expr = self.remove(expr.id).make_expr(),
_ => noop_visit_expr(expr, self),
_ => walk_expr(expr, self),
}
}
fn visit_method_receiver_expr(&mut self, expr: &mut P<ast::Expr>) {
match expr.kind {
ast::ExprKind::MacCall(_) => *expr = self.remove(expr.id).make_method_receiver_expr(),
_ => noop_visit_expr(expr, self),
_ => walk_expr(expr, self),
}
}
@ -322,7 +322,7 @@ impl MutVisitor for PlaceholderExpander {
fn flat_map_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
let (style, mut stmts) = match stmt.kind {
ast::StmtKind::MacCall(mac) => (mac.style, self.remove(stmt.id).make_stmts()),
_ => return noop_flat_map_stmt(stmt, self),
_ => return walk_flat_map_stmt(stmt, self),
};
if style == ast::MacStmtStyle::Semicolon {
@ -368,14 +368,14 @@ impl MutVisitor for PlaceholderExpander {
fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
match pat.kind {
ast::PatKind::MacCall(_) => *pat = self.remove(pat.id).make_pat(),
_ => noop_visit_pat(pat, self),
_ => walk_pat(pat, self),
}
}
fn visit_ty(&mut self, ty: &mut P<ast::Ty>) {
match ty.kind {
ast::TyKind::MacCall(_) => *ty = self.remove(ty.id).make_ty(),
_ => noop_visit_ty(ty, self),
_ => walk_ty(ty, self),
}
}
@ -383,7 +383,7 @@ impl MutVisitor for PlaceholderExpander {
if krate.is_placeholder {
*krate = self.remove(krate.id).make_crate();
} else {
noop_visit_crate(krate, self)
walk_crate(krate, self)
}
}
}

View File

@ -10,7 +10,7 @@ use super::{
use crate::errors;
use crate::maybe_recover_from_interpolated_ty_qpath;
use ast::mut_visit::{noop_visit_expr, MutVisitor};
use ast::mut_visit::{self, MutVisitor};
use ast::token::IdentIsRaw;
use ast::{CoroutineKind, ForLoopKind, GenBlockKind, MatchKind, Pat, Path, PathSegment, Recovered};
use core::mem;
@ -3939,14 +3939,14 @@ impl MutVisitor for CondChecker<'_> {
}
}
ExprKind::Binary(Spanned { node: BinOpKind::And, .. }, _, _) => {
noop_visit_expr(e, self);
mut_visit::walk_expr(e, self);
}
ExprKind::Binary(Spanned { node: BinOpKind::Or, span: or_span }, _, _)
if let None | Some(NotSupportedOr(_)) = self.forbid_let_reason =>
{
let forbid_let_reason = self.forbid_let_reason;
self.forbid_let_reason = Some(NotSupportedOr(or_span));
noop_visit_expr(e, self);
mut_visit::walk_expr(e, self);
self.forbid_let_reason = forbid_let_reason;
}
ExprKind::Paren(ref inner)
@ -3954,7 +3954,7 @@ impl MutVisitor for CondChecker<'_> {
{
let forbid_let_reason = self.forbid_let_reason;
self.forbid_let_reason = Some(NotSupportedParentheses(inner.span));
noop_visit_expr(e, self);
mut_visit::walk_expr(e, self);
self.forbid_let_reason = forbid_let_reason;
}
ExprKind::Assign(ref lhs, _, span) => {
@ -3972,7 +3972,7 @@ impl MutVisitor for CondChecker<'_> {
}
let comparison = self.comparison;
self.comparison = Some(errors::MaybeComparison { span: span.shrink_to_hi() });
noop_visit_expr(e, self);
mut_visit::walk_expr(e, self);
self.forbid_let_reason = forbid_let_reason;
self.missing_let = missing_let;
self.comparison = comparison;
@ -3992,7 +3992,7 @@ impl MutVisitor for CondChecker<'_> {
| ExprKind::Paren(_) => {
let forbid_let_reason = self.forbid_let_reason;
self.forbid_let_reason = Some(OtherForbidden);
noop_visit_expr(e, self);
mut_visit::walk_expr(e, self);
self.forbid_let_reason = forbid_let_reason;
}
ExprKind::Cast(ref mut op, _) | ExprKind::Type(ref mut op, _) => {

View File

@ -12,7 +12,7 @@ use crate::errors::{
};
use crate::parser::expr::{could_be_unclosed_char_literal, LhsExpr};
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
use rustc_ast::mut_visit::{noop_visit_pat, MutVisitor};
use rustc_ast::mut_visit::{walk_pat, MutVisitor};
use rustc_ast::ptr::P;
use rustc_ast::token::{self, BinOpToken, Delimiter, Token};
use rustc_ast::{
@ -810,7 +810,7 @@ impl<'a> Parser<'a> {
self.0 = true;
*m = Mutability::Mut;
}
noop_visit_pat(pat, self);
walk_pat(pat, self);
}
}

View File

@ -121,7 +121,7 @@ fn remove_all_parens(pat: &mut P<Pat>) {
struct Visitor;
impl MutVisitor for Visitor {
fn visit_pat(&mut self, pat: &mut P<Pat>) {
noop_visit_pat(pat, self);
walk_pat(pat, self);
let inner = match &mut pat.kind {
Paren(i) => mem::replace(&mut i.kind, Wild),
_ => return,
@ -138,7 +138,7 @@ fn insert_necessary_parens(pat: &mut P<Pat>) {
impl MutVisitor for Visitor {
fn visit_pat(&mut self, pat: &mut P<Pat>) {
use ast::BindingMode;
noop_visit_pat(pat, self);
walk_pat(pat, self);
let target = match &mut pat.kind {
// `i @ a | b`, `box a | b`, and `& mut? a | b`.
Ident(.., Some(p)) | Box(p) | Ref(p, _) if matches!(&p.kind, Or(ps) if ps.len() > 1) => p,
@ -160,7 +160,7 @@ fn unnest_or_patterns(pat: &mut P<Pat>) -> bool {
impl MutVisitor for Visitor {
fn visit_pat(&mut self, p: &mut P<Pat>) {
// This is a bottom up transformation, so recurse first.
noop_visit_pat(p, self);
walk_pat(p, self);
// Don't have an or-pattern? Just quit early on.
let Or(alternatives) = &mut p.kind else { return };
@ -189,7 +189,7 @@ fn unnest_or_patterns(pat: &mut P<Pat>) -> bool {
// Deal with `Some(Some(0)) | Some(Some(1))`.
if this_level_changed {
noop_visit_pat(p, self);
walk_pat(p, self);
}
}
}

View File

@ -202,7 +202,7 @@ impl MutVisitor for RemoveParens {
ExprKind::Paren(inner) => *e = inner,
_ => {}
};
mut_visit::noop_visit_expr(e, self);
mut_visit::walk_expr(e, self);
}
}
@ -211,7 +211,7 @@ struct AddParens;
impl MutVisitor for AddParens {
fn visit_expr(&mut self, e: &mut P<Expr>) {
mut_visit::noop_visit_expr(e, self);
mut_visit::walk_expr(e, self);
visit_clobber(e, |e| {
P(Expr {
id: DUMMY_NODE_ID,