Remove unnecessary pubs in mut_visit.rs.

This makes it clearer what is actually used outside of this crate.
This commit is contained in:
Nicholas Nethercote 2024-04-24 15:21:16 +10:00
parent 8d4655d9ec
commit 748b0a2e35

View File

@ -335,7 +335,7 @@ pub fn visit_clobber<T: DummyAstNode>(t: &mut T, f: impl FnOnce(T) -> T) {
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
#[inline] #[inline]
pub fn visit_vec<T, F>(elems: &mut Vec<T>, mut visit_elem: F) fn visit_vec<T, F>(elems: &mut Vec<T>, mut visit_elem: F)
where where
F: FnMut(&mut T), F: FnMut(&mut T),
{ {
@ -346,7 +346,7 @@ where
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
#[inline] #[inline]
pub fn visit_thin_vec<T, F>(elems: &mut ThinVec<T>, mut visit_elem: F) fn visit_thin_vec<T, F>(elems: &mut ThinVec<T>, mut visit_elem: F)
where where
F: FnMut(&mut T), F: FnMut(&mut T),
{ {
@ -357,7 +357,7 @@ where
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
#[inline] #[inline]
pub fn visit_opt<T, F>(opt: &mut Option<T>, mut visit_elem: F) fn visit_opt<T, F>(opt: &mut Option<T>, mut visit_elem: F)
where where
F: FnMut(&mut T), F: FnMut(&mut T),
{ {
@ -367,36 +367,37 @@ where
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_attrs<T: MutVisitor>(attrs: &mut AttrVec, vis: &mut T) { fn visit_attrs<T: MutVisitor>(attrs: &mut AttrVec, vis: &mut T) {
for attr in attrs.iter_mut() { for attr in attrs.iter_mut() {
vis.visit_attribute(attr); vis.visit_attribute(attr);
} }
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_exprs<T: MutVisitor>(exprs: &mut Vec<P<Expr>>, vis: &mut T) { #[allow(unused)]
fn visit_exprs<T: MutVisitor>(exprs: &mut Vec<P<Expr>>, vis: &mut T) {
exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr)) exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr))
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_thin_exprs<T: MutVisitor>(exprs: &mut ThinVec<P<Expr>>, vis: &mut T) { fn visit_thin_exprs<T: MutVisitor>(exprs: &mut ThinVec<P<Expr>>, vis: &mut T) {
exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr)) exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr))
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_bounds<T: MutVisitor>(bounds: &mut GenericBounds, vis: &mut T) { fn visit_bounds<T: MutVisitor>(bounds: &mut GenericBounds, vis: &mut T) {
visit_vec(bounds, |bound| vis.visit_param_bound(bound)); visit_vec(bounds, |bound| vis.visit_param_bound(bound));
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_fn_sig<T: MutVisitor>(FnSig { header, decl, span }: &mut FnSig, vis: &mut T) { fn visit_fn_sig<T: MutVisitor>(FnSig { header, decl, span }: &mut FnSig, vis: &mut T) {
vis.visit_fn_header(header); vis.visit_fn_header(header);
vis.visit_fn_decl(decl); vis.visit_fn_decl(decl);
vis.visit_span(span); vis.visit_span(span);
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_attr_args<T: MutVisitor>(args: &mut AttrArgs, vis: &mut T) { fn visit_attr_args<T: MutVisitor>(args: &mut AttrArgs, vis: &mut T) {
match args { match args {
AttrArgs::Empty => {} AttrArgs::Empty => {}
AttrArgs::Delimited(args) => visit_delim_args(args, vis), AttrArgs::Delimited(args) => visit_delim_args(args, vis),
@ -411,7 +412,7 @@ pub fn visit_attr_args<T: MutVisitor>(args: &mut AttrArgs, vis: &mut T) {
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_delim_args<T: MutVisitor>(args: &mut DelimArgs, vis: &mut T) { fn visit_delim_args<T: MutVisitor>(args: &mut DelimArgs, vis: &mut T) {
let DelimArgs { dspan, delim: _, tokens } = args; let DelimArgs { dspan, delim: _, tokens } = args;
visit_delim_span(dspan, vis); visit_delim_span(dspan, vis);
visit_tts(tokens, vis); visit_tts(tokens, vis);
@ -435,7 +436,7 @@ pub fn noop_flat_map_pat_field<T: MutVisitor>(
smallvec![fp] smallvec![fp]
} }
pub fn noop_visit_use_tree<T: MutVisitor>(use_tree: &mut UseTree, vis: &mut T) { fn noop_visit_use_tree<T: MutVisitor>(use_tree: &mut UseTree, vis: &mut T) {
let UseTree { prefix, kind, span } = use_tree; let UseTree { prefix, kind, span } = use_tree;
vis.visit_path(prefix); vis.visit_path(prefix);
match kind { match kind {
@ -462,7 +463,7 @@ pub fn noop_flat_map_arm<T: MutVisitor>(mut arm: Arm, vis: &mut T) -> SmallVec<[
smallvec![arm] smallvec![arm]
} }
pub fn noop_visit_constraint<T: MutVisitor>( fn noop_visit_constraint<T: MutVisitor>(
AssocConstraint { id, ident, gen_args, kind, span }: &mut AssocConstraint, AssocConstraint { id, ident, gen_args, kind, span }: &mut AssocConstraint,
vis: &mut T, vis: &mut T,
) { ) {
@ -541,7 +542,7 @@ pub fn noop_visit_ty<T: MutVisitor>(ty: &mut P<Ty>, vis: &mut T) {
visit_lazy_tts(tokens, vis); visit_lazy_tts(tokens, vis);
} }
pub fn noop_visit_foreign_mod<T: MutVisitor>(foreign_mod: &mut ForeignMod, vis: &mut T) { fn noop_visit_foreign_mod<T: MutVisitor>(foreign_mod: &mut ForeignMod, vis: &mut T) {
let ForeignMod { unsafety, abi: _, items } = foreign_mod; let ForeignMod { unsafety, abi: _, items } = foreign_mod;
visit_unsafety(unsafety, vis); visit_unsafety(unsafety, vis);
items.flat_map_in_place(|item| vis.flat_map_foreign_item(item)); items.flat_map_in_place(|item| vis.flat_map_foreign_item(item));
@ -562,11 +563,11 @@ pub fn noop_flat_map_variant<T: MutVisitor>(
smallvec![variant] smallvec![variant]
} }
pub fn noop_visit_ident<T: MutVisitor>(Ident { name: _, span }: &mut Ident, vis: &mut T) { fn noop_visit_ident<T: MutVisitor>(Ident { name: _, span }: &mut Ident, vis: &mut T) {
vis.visit_span(span); vis.visit_span(span);
} }
pub fn noop_visit_path<T: MutVisitor>(Path { segments, span, tokens }: &mut Path, vis: &mut T) { fn noop_visit_path<T: MutVisitor>(Path { segments, span, tokens }: &mut Path, vis: &mut T) {
vis.visit_span(span); vis.visit_span(span);
for PathSegment { ident, id, args } in segments { for PathSegment { ident, id, args } in segments {
vis.visit_ident(ident); vis.visit_ident(ident);
@ -576,7 +577,7 @@ pub fn noop_visit_path<T: MutVisitor>(Path { segments, span, tokens }: &mut Path
visit_lazy_tts(tokens, vis); visit_lazy_tts(tokens, vis);
} }
pub fn noop_visit_qself<T: MutVisitor>(qself: &mut Option<P<QSelf>>, vis: &mut T) { fn noop_visit_qself<T: MutVisitor>(qself: &mut Option<P<QSelf>>, vis: &mut T) {
visit_opt(qself, |qself| { visit_opt(qself, |qself| {
let QSelf { ty, path_span, position: _ } = &mut **qself; let QSelf { ty, path_span, position: _ } = &mut **qself;
vis.visit_ty(ty); vis.visit_ty(ty);
@ -584,14 +585,14 @@ pub fn noop_visit_qself<T: MutVisitor>(qself: &mut Option<P<QSelf>>, vis: &mut T
}) })
} }
pub fn noop_visit_generic_args<T: MutVisitor>(generic_args: &mut GenericArgs, vis: &mut T) { fn noop_visit_generic_args<T: MutVisitor>(generic_args: &mut GenericArgs, vis: &mut T) {
match generic_args { match generic_args {
GenericArgs::AngleBracketed(data) => vis.visit_angle_bracketed_parameter_data(data), GenericArgs::AngleBracketed(data) => vis.visit_angle_bracketed_parameter_data(data),
GenericArgs::Parenthesized(data) => vis.visit_parenthesized_parameter_data(data), GenericArgs::Parenthesized(data) => vis.visit_parenthesized_parameter_data(data),
} }
} }
pub fn noop_visit_generic_arg<T: MutVisitor>(arg: &mut GenericArg, vis: &mut T) { fn noop_visit_generic_arg<T: MutVisitor>(arg: &mut GenericArg, vis: &mut T) {
match arg { match arg {
GenericArg::Lifetime(lt) => vis.visit_lifetime(lt), GenericArg::Lifetime(lt) => vis.visit_lifetime(lt),
GenericArg::Type(ty) => vis.visit_ty(ty), GenericArg::Type(ty) => vis.visit_ty(ty),
@ -599,7 +600,7 @@ pub fn noop_visit_generic_arg<T: MutVisitor>(arg: &mut GenericArg, vis: &mut T)
} }
} }
pub fn noop_visit_angle_bracketed_parameter_data<T: MutVisitor>( fn noop_visit_angle_bracketed_parameter_data<T: MutVisitor>(
data: &mut AngleBracketedArgs, data: &mut AngleBracketedArgs,
vis: &mut T, vis: &mut T,
) { ) {
@ -611,7 +612,7 @@ pub fn noop_visit_angle_bracketed_parameter_data<T: MutVisitor>(
vis.visit_span(span); vis.visit_span(span);
} }
pub fn noop_visit_parenthesized_parameter_data<T: MutVisitor>( fn noop_visit_parenthesized_parameter_data<T: MutVisitor>(
args: &mut ParenthesizedArgs, args: &mut ParenthesizedArgs,
vis: &mut T, vis: &mut T,
) { ) {
@ -621,7 +622,7 @@ pub fn noop_visit_parenthesized_parameter_data<T: MutVisitor>(
vis.visit_span(span); vis.visit_span(span);
} }
pub fn noop_visit_local<T: MutVisitor>(local: &mut P<Local>, vis: &mut T) { fn noop_visit_local<T: MutVisitor>(local: &mut P<Local>, vis: &mut T) {
let Local { id, pat, ty, kind, span, colon_sp, attrs, tokens } = local.deref_mut(); let Local { id, pat, ty, kind, span, colon_sp, attrs, tokens } = local.deref_mut();
vis.visit_id(id); vis.visit_id(id);
vis.visit_pat(pat); vis.visit_pat(pat);
@ -642,7 +643,7 @@ pub fn noop_visit_local<T: MutVisitor>(local: &mut P<Local>, vis: &mut T) {
visit_lazy_tts(tokens, vis); visit_lazy_tts(tokens, vis);
} }
pub fn noop_visit_attribute<T: MutVisitor>(attr: &mut Attribute, vis: &mut T) { fn noop_visit_attribute<T: MutVisitor>(attr: &mut Attribute, vis: &mut T) {
let Attribute { kind, id: _, style: _, span } = attr; let Attribute { kind, id: _, style: _, span } = attr;
match kind { match kind {
AttrKind::Normal(normal) => { AttrKind::Normal(normal) => {
@ -658,25 +659,25 @@ pub fn noop_visit_attribute<T: MutVisitor>(attr: &mut Attribute, vis: &mut T) {
vis.visit_span(span); vis.visit_span(span);
} }
pub fn noop_visit_mac<T: MutVisitor>(mac: &mut MacCall, vis: &mut T) { fn noop_visit_mac<T: MutVisitor>(mac: &mut MacCall, vis: &mut T) {
let MacCall { path, args } = mac; let MacCall { path, args } = mac;
vis.visit_path(path); vis.visit_path(path);
visit_delim_args(args, vis); visit_delim_args(args, vis);
} }
pub fn noop_visit_macro_def<T: MutVisitor>(macro_def: &mut MacroDef, vis: &mut T) { fn noop_visit_macro_def<T: MutVisitor>(macro_def: &mut MacroDef, vis: &mut T) {
let MacroDef { body, macro_rules: _ } = macro_def; let MacroDef { body, macro_rules: _ } = macro_def;
visit_delim_args(body, vis); visit_delim_args(body, vis);
} }
pub fn noop_visit_meta_list_item<T: MutVisitor>(li: &mut NestedMetaItem, vis: &mut T) { fn noop_visit_meta_list_item<T: MutVisitor>(li: &mut NestedMetaItem, vis: &mut T) {
match li { match li {
NestedMetaItem::MetaItem(mi) => vis.visit_meta_item(mi), NestedMetaItem::MetaItem(mi) => vis.visit_meta_item(mi),
NestedMetaItem::Lit(_lit) => {} NestedMetaItem::Lit(_lit) => {}
} }
} }
pub fn noop_visit_meta_item<T: MutVisitor>(mi: &mut MetaItem, vis: &mut T) { fn noop_visit_meta_item<T: MutVisitor>(mi: &mut MetaItem, vis: &mut T) {
let MetaItem { path: _, kind, span } = mi; let MetaItem { path: _, kind, span } = mi;
match kind { match kind {
MetaItemKind::Word => {} MetaItemKind::Word => {}
@ -697,7 +698,7 @@ pub fn noop_flat_map_param<T: MutVisitor>(mut param: Param, vis: &mut T) -> Smal
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_attr_tt<T: MutVisitor>(tt: &mut AttrTokenTree, vis: &mut T) { fn visit_attr_tt<T: MutVisitor>(tt: &mut AttrTokenTree, vis: &mut T) {
match tt { match tt {
AttrTokenTree::Token(token, _) => { AttrTokenTree::Token(token, _) => {
visit_token(token, vis); visit_token(token, vis);
@ -724,7 +725,7 @@ pub fn visit_attr_tt<T: MutVisitor>(tt: &mut AttrTokenTree, vis: &mut T) {
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_tt<T: MutVisitor>(tt: &mut TokenTree, vis: &mut T) { fn visit_tt<T: MutVisitor>(tt: &mut TokenTree, vis: &mut T) {
match tt { match tt {
TokenTree::Token(token, _) => { TokenTree::Token(token, _) => {
visit_token(token, vis); visit_token(token, vis);
@ -738,24 +739,21 @@ pub fn visit_tt<T: MutVisitor>(tt: &mut TokenTree, vis: &mut T) {
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_tts<T: MutVisitor>(TokenStream(tts): &mut TokenStream, vis: &mut T) { fn visit_tts<T: MutVisitor>(TokenStream(tts): &mut TokenStream, vis: &mut T) {
if T::VISIT_TOKENS && !tts.is_empty() { if T::VISIT_TOKENS && !tts.is_empty() {
let tts = Lrc::make_mut(tts); let tts = Lrc::make_mut(tts);
visit_vec(tts, |tree| visit_tt(tree, vis)); visit_vec(tts, |tree| visit_tt(tree, vis));
} }
} }
pub fn visit_attr_tts<T: MutVisitor>(AttrTokenStream(tts): &mut AttrTokenStream, vis: &mut T) { fn visit_attr_tts<T: MutVisitor>(AttrTokenStream(tts): &mut AttrTokenStream, vis: &mut T) {
if T::VISIT_TOKENS && !tts.is_empty() { if T::VISIT_TOKENS && !tts.is_empty() {
let tts = Lrc::make_mut(tts); let tts = Lrc::make_mut(tts);
visit_vec(tts, |tree| visit_attr_tt(tree, vis)); visit_vec(tts, |tree| visit_attr_tt(tree, vis));
} }
} }
pub fn visit_lazy_tts_opt_mut<T: MutVisitor>( fn visit_lazy_tts_opt_mut<T: MutVisitor>(lazy_tts: Option<&mut LazyAttrTokenStream>, vis: &mut T) {
lazy_tts: Option<&mut LazyAttrTokenStream>,
vis: &mut T,
) {
if T::VISIT_TOKENS { if T::VISIT_TOKENS {
if let Some(lazy_tts) = lazy_tts { if let Some(lazy_tts) = lazy_tts {
let mut tts = lazy_tts.to_attr_token_stream(); let mut tts = lazy_tts.to_attr_token_stream();
@ -765,7 +763,7 @@ pub fn visit_lazy_tts_opt_mut<T: MutVisitor>(
} }
} }
pub fn visit_lazy_tts<T: MutVisitor>(lazy_tts: &mut Option<LazyAttrTokenStream>, vis: &mut T) { fn visit_lazy_tts<T: MutVisitor>(lazy_tts: &mut Option<LazyAttrTokenStream>, vis: &mut T) {
visit_lazy_tts_opt_mut(lazy_tts.as_mut(), vis); visit_lazy_tts_opt_mut(lazy_tts.as_mut(), vis);
} }
@ -818,7 +816,7 @@ pub fn visit_token<T: MutVisitor>(t: &mut Token, vis: &mut T) {
// contain multiple items, but decided against it when I looked at // contain multiple items, but decided against it when I looked at
// `parse_item_or_view_item` and tried to figure out what I would do with // `parse_item_or_view_item` and tried to figure out what I would do with
// multiple items there.... // multiple items there....
pub fn visit_nonterminal<T: MutVisitor>(nt: &mut token::Nonterminal, vis: &mut T) { fn visit_nonterminal<T: MutVisitor>(nt: &mut token::Nonterminal, vis: &mut T) {
match nt { match nt {
token::NtItem(item) => visit_clobber(item, |item| { token::NtItem(item) => visit_clobber(item, |item| {
// This is probably okay, because the only visitors likely to // This is probably okay, because the only visitors likely to
@ -851,7 +849,7 @@ pub fn visit_nonterminal<T: MutVisitor>(nt: &mut token::Nonterminal, vis: &mut T
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_defaultness<T: MutVisitor>(defaultness: &mut Defaultness, vis: &mut T) { fn visit_defaultness<T: MutVisitor>(defaultness: &mut Defaultness, vis: &mut T) {
match defaultness { match defaultness {
Defaultness::Default(span) => vis.visit_span(span), Defaultness::Default(span) => vis.visit_span(span),
Defaultness::Final => {} Defaultness::Final => {}
@ -859,7 +857,7 @@ pub fn visit_defaultness<T: MutVisitor>(defaultness: &mut Defaultness, vis: &mut
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_unsafety<T: MutVisitor>(unsafety: &mut Unsafe, vis: &mut T) { fn visit_unsafety<T: MutVisitor>(unsafety: &mut Unsafe, vis: &mut T) {
match unsafety { match unsafety {
Unsafe::Yes(span) => vis.visit_span(span), Unsafe::Yes(span) => vis.visit_span(span),
Unsafe::No => {} Unsafe::No => {}
@ -867,7 +865,7 @@ pub fn visit_unsafety<T: MutVisitor>(unsafety: &mut Unsafe, vis: &mut T) {
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_polarity<T: MutVisitor>(polarity: &mut ImplPolarity, vis: &mut T) { fn visit_polarity<T: MutVisitor>(polarity: &mut ImplPolarity, vis: &mut T) {
match polarity { match polarity {
ImplPolarity::Positive => {} ImplPolarity::Positive => {}
ImplPolarity::Negative(span) => vis.visit_span(span), ImplPolarity::Negative(span) => vis.visit_span(span),
@ -875,14 +873,14 @@ pub fn visit_polarity<T: MutVisitor>(polarity: &mut ImplPolarity, vis: &mut T) {
} }
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_constness<T: MutVisitor>(constness: &mut Const, vis: &mut T) { fn visit_constness<T: MutVisitor>(constness: &mut Const, vis: &mut T) {
match constness { match constness {
Const::Yes(span) => vis.visit_span(span), Const::Yes(span) => vis.visit_span(span),
Const::No => {} Const::No => {}
} }
} }
pub fn noop_visit_closure_binder<T: MutVisitor>(binder: &mut ClosureBinder, vis: &mut T) { fn noop_visit_closure_binder<T: MutVisitor>(binder: &mut ClosureBinder, vis: &mut T) {
match binder { match binder {
ClosureBinder::NotPresent => {} ClosureBinder::NotPresent => {}
ClosureBinder::For { span: _, generic_params } => { ClosureBinder::For { span: _, generic_params } => {
@ -891,7 +889,7 @@ pub fn noop_visit_closure_binder<T: MutVisitor>(binder: &mut ClosureBinder, vis:
} }
} }
pub fn noop_visit_coroutine_kind<T: MutVisitor>(coroutine_kind: &mut CoroutineKind, vis: &mut T) { fn noop_visit_coroutine_kind<T: MutVisitor>(coroutine_kind: &mut CoroutineKind, vis: &mut T) {
match coroutine_kind { match coroutine_kind {
CoroutineKind::Async { span, closure_id, return_impl_trait_id } CoroutineKind::Async { span, closure_id, return_impl_trait_id }
| CoroutineKind::Gen { span, closure_id, return_impl_trait_id } | CoroutineKind::Gen { span, closure_id, return_impl_trait_id }
@ -903,27 +901,27 @@ pub fn noop_visit_coroutine_kind<T: MutVisitor>(coroutine_kind: &mut CoroutineKi
} }
} }
pub fn noop_visit_fn_decl<T: MutVisitor>(decl: &mut P<FnDecl>, vis: &mut T) { fn noop_visit_fn_decl<T: MutVisitor>(decl: &mut P<FnDecl>, vis: &mut T) {
let FnDecl { inputs, output } = decl.deref_mut(); let FnDecl { inputs, output } = decl.deref_mut();
inputs.flat_map_in_place(|param| vis.flat_map_param(param)); inputs.flat_map_in_place(|param| vis.flat_map_param(param));
noop_visit_fn_ret_ty(output, vis); noop_visit_fn_ret_ty(output, vis);
} }
pub fn noop_visit_fn_ret_ty<T: MutVisitor>(fn_ret_ty: &mut FnRetTy, vis: &mut T) { fn noop_visit_fn_ret_ty<T: MutVisitor>(fn_ret_ty: &mut FnRetTy, vis: &mut T) {
match fn_ret_ty { match fn_ret_ty {
FnRetTy::Default(span) => vis.visit_span(span), FnRetTy::Default(span) => vis.visit_span(span),
FnRetTy::Ty(ty) => vis.visit_ty(ty), FnRetTy::Ty(ty) => vis.visit_ty(ty),
} }
} }
pub fn noop_visit_param_bound<T: MutVisitor>(pb: &mut GenericBound, vis: &mut T) { fn noop_visit_param_bound<T: MutVisitor>(pb: &mut GenericBound, vis: &mut T) {
match pb { match pb {
GenericBound::Trait(ty, _modifier) => vis.visit_poly_trait_ref(ty), GenericBound::Trait(ty, _modifier) => vis.visit_poly_trait_ref(ty),
GenericBound::Outlives(lifetime) => noop_visit_lifetime(lifetime, vis), GenericBound::Outlives(lifetime) => noop_visit_lifetime(lifetime, vis),
} }
} }
pub fn noop_visit_precise_capturing_arg<T: MutVisitor>(arg: &mut PreciseCapturingArg, vis: &mut T) { fn noop_visit_precise_capturing_arg<T: MutVisitor>(arg: &mut PreciseCapturingArg, vis: &mut T) {
match arg { match arg {
PreciseCapturingArg::Lifetime(lt) => { PreciseCapturingArg::Lifetime(lt) => {
vis.visit_lifetime(lt); vis.visit_lifetime(lt);
@ -960,7 +958,7 @@ pub fn noop_flat_map_generic_param<T: MutVisitor>(
smallvec![param] smallvec![param]
} }
pub fn noop_visit_label<T: MutVisitor>(Label { ident }: &mut Label, vis: &mut T) { fn noop_visit_label<T: MutVisitor>(Label { ident }: &mut Label, vis: &mut T) {
vis.visit_ident(ident); vis.visit_ident(ident);
} }
@ -969,20 +967,20 @@ fn noop_visit_lifetime<T: MutVisitor>(Lifetime { id, ident }: &mut Lifetime, vis
vis.visit_ident(ident); vis.visit_ident(ident);
} }
pub fn noop_visit_generics<T: MutVisitor>(generics: &mut Generics, vis: &mut T) { fn noop_visit_generics<T: MutVisitor>(generics: &mut Generics, vis: &mut T) {
let Generics { params, where_clause, span } = generics; let Generics { params, where_clause, span } = generics;
params.flat_map_in_place(|param| vis.flat_map_generic_param(param)); params.flat_map_in_place(|param| vis.flat_map_generic_param(param));
vis.visit_where_clause(where_clause); vis.visit_where_clause(where_clause);
vis.visit_span(span); vis.visit_span(span);
} }
pub fn noop_visit_where_clause<T: MutVisitor>(wc: &mut WhereClause, vis: &mut T) { fn noop_visit_where_clause<T: MutVisitor>(wc: &mut WhereClause, vis: &mut T) {
let WhereClause { has_where_token: _, predicates, span } = wc; let WhereClause { has_where_token: _, predicates, span } = wc;
visit_thin_vec(predicates, |predicate| vis.visit_where_predicate(predicate)); visit_thin_vec(predicates, |predicate| vis.visit_where_predicate(predicate));
vis.visit_span(span); vis.visit_span(span);
} }
pub fn noop_visit_where_predicate<T: MutVisitor>(pred: &mut WherePredicate, vis: &mut T) { fn noop_visit_where_predicate<T: MutVisitor>(pred: &mut WherePredicate, vis: &mut T) {
match pred { match pred {
WherePredicate::BoundPredicate(bp) => { WherePredicate::BoundPredicate(bp) => {
let WhereBoundPredicate { span, bound_generic_params, bounded_ty, bounds } = bp; let WhereBoundPredicate { span, bound_generic_params, bounded_ty, bounds } = bp;
@ -1006,7 +1004,7 @@ pub fn noop_visit_where_predicate<T: MutVisitor>(pred: &mut WherePredicate, vis:
} }
} }
pub fn noop_visit_variant_data<T: MutVisitor>(vdata: &mut VariantData, vis: &mut T) { fn noop_visit_variant_data<T: MutVisitor>(vdata: &mut VariantData, vis: &mut T) {
match vdata { match vdata {
VariantData::Struct { fields, .. } => { VariantData::Struct { fields, .. } => {
fields.flat_map_in_place(|field| vis.flat_map_field_def(field)); fields.flat_map_in_place(|field| vis.flat_map_field_def(field));
@ -1019,12 +1017,12 @@ pub fn noop_visit_variant_data<T: MutVisitor>(vdata: &mut VariantData, vis: &mut
} }
} }
pub fn noop_visit_trait_ref<T: MutVisitor>(TraitRef { path, ref_id }: &mut TraitRef, vis: &mut T) { fn noop_visit_trait_ref<T: MutVisitor>(TraitRef { path, ref_id }: &mut TraitRef, vis: &mut T) {
vis.visit_path(path); vis.visit_path(path);
vis.visit_id(ref_id); vis.visit_id(ref_id);
} }
pub fn noop_visit_poly_trait_ref<T: MutVisitor>(p: &mut PolyTraitRef, vis: &mut T) { fn noop_visit_poly_trait_ref<T: MutVisitor>(p: &mut PolyTraitRef, vis: &mut T) {
let PolyTraitRef { bound_generic_params, trait_ref, span } = p; let PolyTraitRef { bound_generic_params, trait_ref, span } = p;
bound_generic_params.flat_map_in_place(|param| vis.flat_map_generic_param(param)); bound_generic_params.flat_map_in_place(|param| vis.flat_map_generic_param(param));
vis.visit_trait_ref(trait_ref); vis.visit_trait_ref(trait_ref);
@ -1058,7 +1056,7 @@ pub fn noop_flat_map_expr_field<T: MutVisitor>(
smallvec![f] smallvec![f]
} }
pub fn noop_visit_mt<T: MutVisitor>(MutTy { ty, mutbl: _ }: &mut MutTy, vis: &mut T) { fn noop_visit_mt<T: MutVisitor>(MutTy { ty, mutbl: _ }: &mut MutTy, vis: &mut T) {
vis.visit_ty(ty); vis.visit_ty(ty);
} }
@ -1219,7 +1217,7 @@ fn visit_const_item<T: MutVisitor>(
visit_opt(expr, |expr| visitor.visit_expr(expr)); visit_opt(expr, |expr| visitor.visit_expr(expr));
} }
pub fn noop_visit_fn_header<T: MutVisitor>(header: &mut FnHeader, vis: &mut T) { fn noop_visit_fn_header<T: MutVisitor>(header: &mut FnHeader, vis: &mut T) {
let FnHeader { unsafety, coroutine_kind, constness, ext: _ } = header; let FnHeader { unsafety, coroutine_kind, constness, ext: _ } = header;
visit_constness(constness, vis); visit_constness(constness, vis);
coroutine_kind.as_mut().map(|coroutine_kind| vis.visit_coroutine_kind(coroutine_kind)); coroutine_kind.as_mut().map(|coroutine_kind| vis.visit_coroutine_kind(coroutine_kind));
@ -1337,12 +1335,12 @@ pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
visit_lazy_tts(tokens, vis); visit_lazy_tts(tokens, vis);
} }
pub fn noop_visit_anon_const<T: MutVisitor>(AnonConst { id, value }: &mut AnonConst, vis: &mut T) { fn noop_visit_anon_const<T: MutVisitor>(AnonConst { id, value }: &mut AnonConst, vis: &mut T) {
vis.visit_id(id); vis.visit_id(id);
vis.visit_expr(value); vis.visit_expr(value);
} }
pub fn noop_visit_inline_asm<T: MutVisitor>(asm: &mut InlineAsm, vis: &mut T) { fn noop_visit_inline_asm<T: MutVisitor>(asm: &mut InlineAsm, vis: &mut T) {
for (op, _) in &mut asm.operands { for (op, _) in &mut asm.operands {
match op { match op {
InlineAsmOperand::In { expr, .. } InlineAsmOperand::In { expr, .. }
@ -1362,7 +1360,7 @@ pub fn noop_visit_inline_asm<T: MutVisitor>(asm: &mut InlineAsm, vis: &mut T) {
} }
} }
pub fn noop_visit_inline_asm_sym<T: MutVisitor>( fn noop_visit_inline_asm_sym<T: MutVisitor>(
InlineAsmSym { id, qself, path }: &mut InlineAsmSym, InlineAsmSym { id, qself, path }: &mut InlineAsmSym,
vis: &mut T, vis: &mut T,
) { ) {
@ -1371,7 +1369,7 @@ pub fn noop_visit_inline_asm_sym<T: MutVisitor>(
vis.visit_path(path); vis.visit_path(path);
} }
pub fn noop_visit_format_args<T: MutVisitor>(fmt: &mut FormatArgs, vis: &mut T) { fn noop_visit_format_args<T: MutVisitor>(fmt: &mut FormatArgs, vis: &mut T) {
for arg in fmt.arguments.all_args_mut() { for arg in fmt.arguments.all_args_mut() {
if let FormatArgumentKind::Named(name) = &mut arg.kind { if let FormatArgumentKind::Named(name) = &mut arg.kind {
vis.visit_ident(name); vis.visit_ident(name);
@ -1588,10 +1586,7 @@ pub fn noop_flat_map_stmt<T: MutVisitor>(
stmts stmts
} }
pub fn noop_flat_map_stmt_kind<T: MutVisitor>( fn noop_flat_map_stmt_kind<T: MutVisitor>(kind: StmtKind, vis: &mut T) -> SmallVec<[StmtKind; 1]> {
kind: StmtKind,
vis: &mut T,
) -> SmallVec<[StmtKind; 1]> {
match kind { match kind {
StmtKind::Let(mut local) => smallvec![StmtKind::Let({ StmtKind::Let(mut local) => smallvec![StmtKind::Let({
vis.visit_local(&mut local); vis.visit_local(&mut local);
@ -1611,7 +1606,7 @@ pub fn noop_flat_map_stmt_kind<T: MutVisitor>(
} }
} }
pub fn noop_visit_vis<T: MutVisitor>(visibility: &mut Visibility, vis: &mut T) { fn noop_visit_vis<T: MutVisitor>(visibility: &mut Visibility, vis: &mut T) {
match &mut visibility.kind { match &mut visibility.kind {
VisibilityKind::Public | VisibilityKind::Inherited => {} VisibilityKind::Public | VisibilityKind::Inherited => {}
VisibilityKind::Restricted { path, id, shorthand: _ } => { VisibilityKind::Restricted { path, id, shorthand: _ } => {
@ -1622,7 +1617,7 @@ pub fn noop_visit_vis<T: MutVisitor>(visibility: &mut Visibility, vis: &mut T) {
vis.visit_span(&mut visibility.span); vis.visit_span(&mut visibility.span);
} }
pub fn noop_visit_capture_by<T: MutVisitor>(capture_by: &mut CaptureBy, vis: &mut T) { fn noop_visit_capture_by<T: MutVisitor>(capture_by: &mut CaptureBy, vis: &mut T) {
match capture_by { match capture_by {
CaptureBy::Ref => {} CaptureBy::Ref => {}
CaptureBy::Value { move_kw } => { CaptureBy::Value { move_kw } => {