diff --git a/codegen/src/fold.rs b/codegen/src/fold.rs index 39a0d8bc60..626fc263fb 100644 --- a/codegen/src/fold.rs +++ b/codegen/src/fold.rs @@ -1,3 +1,4 @@ +use crate::cfg::{self, DocCfg}; use crate::{file, full, gen}; use anyhow::Result; use proc_macro2::{Ident, Span, TokenStream}; @@ -32,10 +33,16 @@ fn visit( } Type::Vec(t) => { let Type::Syn(t) = &**t else { unimplemented!() }; - let method = method_name(t); - Some(quote! { - fold_vec(#name, f, F::#method) - }) + if t == "Attribute" { + Some(quote! { + f.fold_attributes(#name) + }) + } else { + let method = method_name(t); + Some(quote! { + fold_vec(#name, f, F::#method) + }) + } } Type::Punctuated(p) => { let t = &*p.element; @@ -214,6 +221,16 @@ fn node(traits: &mut TokenStream, impls: &mut TokenStream, s: &Node, defs: &Defi #fold_impl } }); + + if s.ident == "Attribute" { + let features = cfg::features(&s.features, DocCfg::Ordinary); + traits.extend(quote! { + #features + fn fold_attributes(&mut self, i: Vec) -> Vec { + fold_vec(i, self, Self::fold_attribute) + } + }); + } } pub fn generate(defs: &Definitions) -> Result<()> { diff --git a/codegen/src/visit_mut.rs b/codegen/src/visit_mut.rs index bd37a3ac54..b049a868a0 100644 --- a/codegen/src/visit_mut.rs +++ b/codegen/src/visit_mut.rs @@ -1,3 +1,4 @@ +use crate::cfg::{self, DocCfg}; use crate::operand::{Borrowed, Operand, Owned}; use crate::{file, full, gen}; use anyhow::Result; @@ -36,14 +37,20 @@ fn visit( visit(t, features, defs, &Owned(quote!(*#name))) } Type::Vec(t) => { - let operand = Borrowed(quote!(it)); - let val = visit(t, features, defs, &operand)?; let name = name.ref_mut_tokens(); - Some(quote! { - for it in #name { - #val; - } - }) + if matches!(&**t, Type::Syn(t) if t == "Attribute") { + Some(quote! { + v.visit_attributes_mut(#name); + }) + } else { + let operand = Borrowed(quote!(it)); + let val = visit(t, features, defs, &operand)?; + Some(quote! { + for it in #name { + #val; + } + }) + } } Type::Punctuated(p) => { let operand = Borrowed(quote!(it)); @@ -193,6 +200,18 @@ fn node(traits: &mut TokenStream, impls: &mut TokenStream, s: &Node, defs: &Defi #visit_mut_impl } }); + + if s.ident == "Attribute" { + let features = cfg::features(&s.features, DocCfg::Ordinary); + traits.extend(quote! { + #features + fn visit_attributes_mut(&mut self, i: &mut Vec) { + for attr in i { + self.visit_attribute_mut(attr); + } + } + }); + } } pub fn generate(defs: &Definitions) -> Result<()> { diff --git a/src/gen/fold.rs b/src/gen/fold.rs index 1e6b724a67..6ad62945e9 100644 --- a/src/gen/fold.rs +++ b/src/gen/fold.rs @@ -65,6 +65,11 @@ pub trait Fold { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] + fn fold_attributes(&mut self, i: Vec) -> Vec { + fold_vec(i, self, Self::fold_attribute) + } + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_bare_fn_arg(&mut self, i: crate::BareFnArg) -> crate::BareFnArg { fold_bare_fn_arg(self, i) } @@ -1046,7 +1051,7 @@ where F: Fold + ?Sized, { crate::Arm { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), pat: f.fold_pat(node.pat), guard: (node.guard).map(|it| ((it).0, Box::new(f.fold_expr(*(it).1)))), fat_arrow_token: node.fat_arrow_token, @@ -1111,7 +1116,7 @@ where F: Fold + ?Sized, { crate::BareFnArg { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), name: (node.name).map(|it| (f.fold_ident((it).0), (it).1)), ty: f.fold_type(node.ty), } @@ -1123,7 +1128,7 @@ where F: Fold + ?Sized, { crate::BareVariadic { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), name: (node.name).map(|it| (f.fold_ident((it).0), (it).1)), dots: node.dots, comma: node.comma, @@ -1218,7 +1223,7 @@ where F: Fold + ?Sized, { crate::ConstParam { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), const_token: node.const_token, ident: f.fold_ident(node.ident), colon_token: node.colon_token, @@ -1298,7 +1303,7 @@ where F: Fold + ?Sized, { crate::DeriveInput { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), @@ -1429,7 +1434,7 @@ where F: Fold + ?Sized, { crate::ExprArray { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), bracket_token: node.bracket_token, elems: crate::punctuated::fold(node.elems, f, F::fold_expr), } @@ -1441,7 +1446,7 @@ where F: Fold + ?Sized, { crate::ExprAssign { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), left: Box::new(f.fold_expr(*node.left)), eq_token: node.eq_token, right: Box::new(f.fold_expr(*node.right)), @@ -1454,7 +1459,7 @@ where F: Fold + ?Sized, { crate::ExprAsync { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), async_token: node.async_token, capture: node.capture, block: f.fold_block(node.block), @@ -1467,7 +1472,7 @@ where F: Fold + ?Sized, { crate::ExprAwait { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), base: Box::new(f.fold_expr(*node.base)), dot_token: node.dot_token, await_token: node.await_token, @@ -1480,7 +1485,7 @@ where F: Fold + ?Sized, { crate::ExprBinary { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), left: Box::new(f.fold_expr(*node.left)), op: f.fold_bin_op(node.op), right: Box::new(f.fold_expr(*node.right)), @@ -1493,7 +1498,7 @@ where F: Fold + ?Sized, { crate::ExprBlock { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), label: (node.label).map(|it| f.fold_label(it)), block: f.fold_block(node.block), } @@ -1505,7 +1510,7 @@ where F: Fold + ?Sized, { crate::ExprBreak { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), break_token: node.break_token, label: (node.label).map(|it| f.fold_lifetime(it)), expr: (node.expr).map(|it| Box::new(f.fold_expr(*it))), @@ -1518,7 +1523,7 @@ where F: Fold + ?Sized, { crate::ExprCall { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), func: Box::new(f.fold_expr(*node.func)), paren_token: node.paren_token, args: crate::punctuated::fold(node.args, f, F::fold_expr), @@ -1531,7 +1536,7 @@ where F: Fold + ?Sized, { crate::ExprCast { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), expr: Box::new(f.fold_expr(*node.expr)), as_token: node.as_token, ty: Box::new(f.fold_type(*node.ty)), @@ -1544,7 +1549,7 @@ where F: Fold + ?Sized, { crate::ExprClosure { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)), constness: node.constness, movability: node.movability, @@ -1564,7 +1569,7 @@ where F: Fold + ?Sized, { crate::ExprConst { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), const_token: node.const_token, block: f.fold_block(node.block), } @@ -1576,7 +1581,7 @@ where F: Fold + ?Sized, { crate::ExprContinue { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), continue_token: node.continue_token, label: (node.label).map(|it| f.fold_lifetime(it)), } @@ -1588,7 +1593,7 @@ where F: Fold + ?Sized, { crate::ExprField { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), base: Box::new(f.fold_expr(*node.base)), dot_token: node.dot_token, member: f.fold_member(node.member), @@ -1601,7 +1606,7 @@ where F: Fold + ?Sized, { crate::ExprForLoop { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), label: (node.label).map(|it| f.fold_label(it)), for_token: node.for_token, pat: Box::new(f.fold_pat(*node.pat)), @@ -1617,7 +1622,7 @@ where F: Fold + ?Sized, { crate::ExprGroup { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), group_token: node.group_token, expr: Box::new(f.fold_expr(*node.expr)), } @@ -1629,7 +1634,7 @@ where F: Fold + ?Sized, { crate::ExprIf { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), if_token: node.if_token, cond: Box::new(f.fold_expr(*node.cond)), then_branch: f.fold_block(node.then_branch), @@ -1644,7 +1649,7 @@ where F: Fold + ?Sized, { crate::ExprIndex { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), expr: Box::new(f.fold_expr(*node.expr)), bracket_token: node.bracket_token, index: Box::new(f.fold_expr(*node.index)), @@ -1657,7 +1662,7 @@ where F: Fold + ?Sized, { crate::ExprInfer { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), underscore_token: node.underscore_token, } } @@ -1668,7 +1673,7 @@ where F: Fold + ?Sized, { crate::ExprLet { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), let_token: node.let_token, pat: Box::new(f.fold_pat(*node.pat)), eq_token: node.eq_token, @@ -1682,7 +1687,7 @@ where F: Fold + ?Sized, { crate::ExprLit { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), lit: f.fold_lit(node.lit), } } @@ -1693,7 +1698,7 @@ where F: Fold + ?Sized, { crate::ExprLoop { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), label: (node.label).map(|it| f.fold_label(it)), loop_token: node.loop_token, body: f.fold_block(node.body), @@ -1706,7 +1711,7 @@ where F: Fold + ?Sized, { crate::ExprMacro { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), mac: f.fold_macro(node.mac), } } @@ -1717,7 +1722,7 @@ where F: Fold + ?Sized, { crate::ExprMatch { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), match_token: node.match_token, expr: Box::new(f.fold_expr(*node.expr)), brace_token: node.brace_token, @@ -1734,7 +1739,7 @@ where F: Fold + ?Sized, { crate::ExprMethodCall { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), receiver: Box::new(f.fold_expr(*node.receiver)), dot_token: node.dot_token, method: f.fold_ident(node.method), @@ -1751,7 +1756,7 @@ where F: Fold + ?Sized, { crate::ExprParen { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), paren_token: node.paren_token, expr: Box::new(f.fold_expr(*node.expr)), } @@ -1763,7 +1768,7 @@ where F: Fold + ?Sized, { crate::ExprPath { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), qself: (node.qself).map(|it| f.fold_qself(it)), path: f.fold_path(node.path), } @@ -1775,7 +1780,7 @@ where F: Fold + ?Sized, { crate::ExprRange { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), start: (node.start).map(|it| Box::new(f.fold_expr(*it))), limits: f.fold_range_limits(node.limits), end: (node.end).map(|it| Box::new(f.fold_expr(*it))), @@ -1788,7 +1793,7 @@ where F: Fold + ?Sized, { crate::ExprRawAddr { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), and_token: node.and_token, raw: node.raw, mutability: f.fold_pointer_mutability(node.mutability), @@ -1805,7 +1810,7 @@ where F: Fold + ?Sized, { crate::ExprReference { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), and_token: node.and_token, mutability: node.mutability, expr: Box::new(f.fold_expr(*node.expr)), @@ -1818,7 +1823,7 @@ where F: Fold + ?Sized, { crate::ExprRepeat { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), bracket_token: node.bracket_token, expr: Box::new(f.fold_expr(*node.expr)), semi_token: node.semi_token, @@ -1832,7 +1837,7 @@ where F: Fold + ?Sized, { crate::ExprReturn { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), return_token: node.return_token, expr: (node.expr).map(|it| Box::new(f.fold_expr(*it))), } @@ -1844,7 +1849,7 @@ where F: Fold + ?Sized, { crate::ExprStruct { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), qself: (node.qself).map(|it| f.fold_qself(it)), path: f.fold_path(node.path), brace_token: node.brace_token, @@ -1860,7 +1865,7 @@ where F: Fold + ?Sized, { crate::ExprTry { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), expr: Box::new(f.fold_expr(*node.expr)), question_token: node.question_token, } @@ -1875,7 +1880,7 @@ where F: Fold + ?Sized, { crate::ExprTryBlock { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), try_token: node.try_token, block: f.fold_block(node.block), } @@ -1887,7 +1892,7 @@ where F: Fold + ?Sized, { crate::ExprTuple { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), paren_token: node.paren_token, elems: crate::punctuated::fold(node.elems, f, F::fold_expr), } @@ -1899,7 +1904,7 @@ where F: Fold + ?Sized, { crate::ExprUnary { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), op: f.fold_un_op(node.op), expr: Box::new(f.fold_expr(*node.expr)), } @@ -1911,7 +1916,7 @@ where F: Fold + ?Sized, { crate::ExprUnsafe { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), unsafe_token: node.unsafe_token, block: f.fold_block(node.block), } @@ -1923,7 +1928,7 @@ where F: Fold + ?Sized, { crate::ExprWhile { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), label: (node.label).map(|it| f.fold_label(it)), while_token: node.while_token, cond: Box::new(f.fold_expr(*node.cond)), @@ -1937,7 +1942,7 @@ where F: Fold + ?Sized, { crate::ExprYield { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), yield_token: node.yield_token, expr: (node.expr).map(|it| Box::new(f.fold_expr(*it))), } @@ -1949,7 +1954,7 @@ where F: Fold + ?Sized, { crate::Field { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), mutability: f.fold_field_mutability(node.mutability), ident: (node.ident).map(|it| f.fold_ident(it)), @@ -1977,7 +1982,7 @@ where F: Fold + ?Sized, { crate::FieldPat { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), member: f.fold_member(node.member), colon_token: node.colon_token, pat: Box::new(f.fold_pat(*node.pat)), @@ -1990,7 +1995,7 @@ where F: Fold + ?Sized, { crate::FieldValue { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), member: f.fold_member(node.member), colon_token: node.colon_token, expr: f.fold_expr(node.expr), @@ -2045,7 +2050,7 @@ where { crate::File { shebang: node.shebang, - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), items: fold_vec(node.items, f, F::fold_item), } } @@ -2098,7 +2103,7 @@ where F: Fold + ?Sized, { crate::ForeignItemFn { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), sig: f.fold_signature(node.sig), semi_token: node.semi_token, @@ -2114,7 +2119,7 @@ where F: Fold + ?Sized, { crate::ForeignItemMacro { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), mac: f.fold_macro(node.mac), semi_token: node.semi_token, } @@ -2129,7 +2134,7 @@ where F: Fold + ?Sized, { crate::ForeignItemStatic { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), static_token: node.static_token, mutability: f.fold_static_mutability(node.mutability), @@ -2149,7 +2154,7 @@ where F: Fold + ?Sized, { crate::ForeignItemType { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), type_token: node.type_token, ident: f.fold_ident(node.ident), @@ -2259,7 +2264,7 @@ where F: Fold + ?Sized, { crate::ImplItemConst { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), defaultness: node.defaultness, const_token: node.const_token, @@ -2279,7 +2284,7 @@ where F: Fold + ?Sized, { crate::ImplItemFn { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), defaultness: node.defaultness, sig: f.fold_signature(node.sig), @@ -2296,7 +2301,7 @@ where F: Fold + ?Sized, { crate::ImplItemMacro { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), mac: f.fold_macro(node.mac), semi_token: node.semi_token, } @@ -2311,7 +2316,7 @@ where F: Fold + ?Sized, { crate::ImplItemType { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), defaultness: node.defaultness, type_token: node.type_token, @@ -2394,7 +2399,7 @@ where F: Fold + ?Sized, { crate::ItemConst { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), const_token: node.const_token, ident: f.fold_ident(node.ident), @@ -2413,7 +2418,7 @@ where F: Fold + ?Sized, { crate::ItemEnum { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), enum_token: node.enum_token, ident: f.fold_ident(node.ident), @@ -2432,7 +2437,7 @@ where F: Fold + ?Sized, { crate::ItemExternCrate { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), extern_token: node.extern_token, crate_token: node.crate_token, @@ -2448,7 +2453,7 @@ where F: Fold + ?Sized, { crate::ItemFn { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), sig: f.fold_signature(node.sig), block: Box::new(f.fold_block(*node.block)), @@ -2464,7 +2469,7 @@ where F: Fold + ?Sized, { crate::ItemForeignMod { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), unsafety: node.unsafety, abi: f.fold_abi(node.abi), brace_token: node.brace_token, @@ -2478,7 +2483,7 @@ where F: Fold + ?Sized, { crate::ItemImpl { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), defaultness: node.defaultness, unsafety: node.unsafety, impl_token: node.impl_token, @@ -2496,7 +2501,7 @@ where F: Fold + ?Sized, { crate::ItemMacro { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), ident: (node.ident).map(|it| f.fold_ident(it)), mac: f.fold_macro(node.mac), semi_token: node.semi_token, @@ -2509,7 +2514,7 @@ where F: Fold + ?Sized, { crate::ItemMod { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), unsafety: node.unsafety, mod_token: node.mod_token, @@ -2525,7 +2530,7 @@ where F: Fold + ?Sized, { crate::ItemStatic { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), static_token: node.static_token, mutability: f.fold_static_mutability(node.mutability), @@ -2544,7 +2549,7 @@ where F: Fold + ?Sized, { crate::ItemStruct { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), struct_token: node.struct_token, ident: f.fold_ident(node.ident), @@ -2560,7 +2565,7 @@ where F: Fold + ?Sized, { crate::ItemTrait { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), unsafety: node.unsafety, auto_token: node.auto_token, @@ -2588,7 +2593,7 @@ where F: Fold + ?Sized, { crate::ItemTraitAlias { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), trait_token: node.trait_token, ident: f.fold_ident(node.ident), @@ -2605,7 +2610,7 @@ where F: Fold + ?Sized, { crate::ItemType { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), type_token: node.type_token, ident: f.fold_ident(node.ident), @@ -2622,7 +2627,7 @@ where F: Fold + ?Sized, { crate::ItemUnion { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), union_token: node.union_token, ident: f.fold_ident(node.ident), @@ -2637,7 +2642,7 @@ where F: Fold + ?Sized, { crate::ItemUse { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), vis: f.fold_visibility(node.vis), use_token: node.use_token, leading_colon: node.leading_colon, @@ -2675,7 +2680,7 @@ where F: Fold + ?Sized, { crate::LifetimeParam { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), lifetime: f.fold_lifetime(node.lifetime), colon_token: node.colon_token, bounds: crate::punctuated::fold(node.bounds, f, F::fold_lifetime), @@ -2778,7 +2783,7 @@ where F: Fold + ?Sized, { crate::Local { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), let_token: node.let_token, pat: f.fold_pat(node.pat), init: (node.init).map(|it| f.fold_local_init(it)), @@ -2941,7 +2946,7 @@ where F: Fold + ?Sized, { crate::PatIdent { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), by_ref: node.by_ref, mutability: node.mutability, ident: f.fold_ident(node.ident), @@ -2955,7 +2960,7 @@ where F: Fold + ?Sized, { crate::PatOr { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), leading_vert: node.leading_vert, cases: crate::punctuated::fold(node.cases, f, F::fold_pat), } @@ -2967,7 +2972,7 @@ where F: Fold + ?Sized, { crate::PatParen { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), paren_token: node.paren_token, pat: Box::new(f.fold_pat(*node.pat)), } @@ -2979,7 +2984,7 @@ where F: Fold + ?Sized, { crate::PatReference { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), and_token: node.and_token, mutability: node.mutability, pat: Box::new(f.fold_pat(*node.pat)), @@ -2992,7 +2997,7 @@ where F: Fold + ?Sized, { crate::PatRest { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), dot2_token: node.dot2_token, } } @@ -3003,7 +3008,7 @@ where F: Fold + ?Sized, { crate::PatSlice { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), bracket_token: node.bracket_token, elems: crate::punctuated::fold(node.elems, f, F::fold_pat), } @@ -3015,7 +3020,7 @@ where F: Fold + ?Sized, { crate::PatStruct { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), qself: (node.qself).map(|it| f.fold_qself(it)), path: f.fold_path(node.path), brace_token: node.brace_token, @@ -3030,7 +3035,7 @@ where F: Fold + ?Sized, { crate::PatTuple { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), paren_token: node.paren_token, elems: crate::punctuated::fold(node.elems, f, F::fold_pat), } @@ -3045,7 +3050,7 @@ where F: Fold + ?Sized, { crate::PatTupleStruct { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), qself: (node.qself).map(|it| f.fold_qself(it)), path: f.fold_path(node.path), paren_token: node.paren_token, @@ -3059,7 +3064,7 @@ where F: Fold + ?Sized, { crate::PatType { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), pat: Box::new(f.fold_pat(*node.pat)), colon_token: node.colon_token, ty: Box::new(f.fold_type(*node.ty)), @@ -3072,7 +3077,7 @@ where F: Fold + ?Sized, { crate::PatWild { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), underscore_token: node.underscore_token, } } @@ -3220,7 +3225,7 @@ where F: Fold + ?Sized, { crate::Receiver { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), reference: (node.reference) .map(|it| ((it).0, ((it).1).map(|it| f.fold_lifetime(it)))), mutability: node.mutability, @@ -3308,7 +3313,7 @@ where F: Fold + ?Sized, { crate::StmtMacro { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), mac: f.fold_macro(node.mac), semi_token: node.semi_token, } @@ -3374,7 +3379,7 @@ where F: Fold + ?Sized, { crate::TraitItemConst { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), const_token: node.const_token, ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), @@ -3391,7 +3396,7 @@ where F: Fold + ?Sized, { crate::TraitItemFn { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), sig: f.fold_signature(node.sig), default: (node.default).map(|it| f.fold_block(it)), semi_token: node.semi_token, @@ -3407,7 +3412,7 @@ where F: Fold + ?Sized, { crate::TraitItemMacro { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), mac: f.fold_macro(node.mac), semi_token: node.semi_token, } @@ -3422,7 +3427,7 @@ where F: Fold + ?Sized, { crate::TraitItemType { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), type_token: node.type_token, ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), @@ -3572,7 +3577,7 @@ where F: Fold + ?Sized, { crate::TypeParam { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), ident: f.fold_ident(node.ident), colon_token: node.colon_token, bounds: crate::punctuated::fold(node.bounds, f, F::fold_type_param_bound), @@ -3791,7 +3796,7 @@ where F: Fold + ?Sized, { crate::Variadic { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), pat: (node.pat).map(|it| (Box::new(f.fold_pat(*(it).0)), (it).1)), dots: node.dots, comma: node.comma, @@ -3804,7 +3809,7 @@ where F: Fold + ?Sized, { crate::Variant { - attrs: fold_vec(node.attrs, f, F::fold_attribute), + attrs: f.fold_attributes(node.attrs), ident: f.fold_ident(node.ident), fields: f.fold_fields(node.fields), discriminant: (node.discriminant).map(|it| ((it).0, f.fold_expr((it).1))), diff --git a/src/gen/visit_mut.rs b/src/gen/visit_mut.rs index c7458b1312..72570094df 100644 --- a/src/gen/visit_mut.rs +++ b/src/gen/visit_mut.rs @@ -67,6 +67,13 @@ pub trait VisitMut { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] + fn visit_attributes_mut(&mut self, i: &mut Vec) { + for attr in i { + self.visit_attribute_mut(attr); + } + } + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_bare_fn_arg_mut(&mut self, i: &mut crate::BareFnArg) { visit_bare_fn_arg_mut(self, i); } @@ -979,9 +986,7 @@ pub fn visit_arm_mut(v: &mut V, node: &mut crate::Arm) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_pat_mut(&mut node.pat); if let Some(it) = &mut node.guard { skip!((it).0); @@ -1047,9 +1052,7 @@ pub fn visit_bare_fn_arg_mut(v: &mut V, node: &mut crate::BareFnArg) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.name { v.visit_ident_mut(&mut (it).0); skip!((it).1); @@ -1062,9 +1065,7 @@ pub fn visit_bare_variadic_mut(v: &mut V, node: &mut crate::BareVariadic) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.name { v.visit_ident_mut(&mut (it).0); skip!((it).1); @@ -1211,9 +1212,7 @@ pub fn visit_const_param_mut(v: &mut V, node: &mut crate::ConstParam) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.const_token); v.visit_ident_mut(&mut node.ident); skip!(node.colon_token); @@ -1295,9 +1294,7 @@ pub fn visit_derive_input_mut(v: &mut V, node: &mut crate::DeriveInput) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); @@ -1438,9 +1435,7 @@ pub fn visit_expr_array_mut(v: &mut V, node: &mut crate::ExprArray) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.bracket_token); for mut el in Punctuated::pairs_mut(&mut node.elems) { let it = el.value_mut(); @@ -1453,9 +1448,7 @@ pub fn visit_expr_assign_mut(v: &mut V, node: &mut crate::ExprAssign) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_expr_mut(&mut *node.left); skip!(node.eq_token); v.visit_expr_mut(&mut *node.right); @@ -1466,9 +1459,7 @@ pub fn visit_expr_async_mut(v: &mut V, node: &mut crate::ExprAsync) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.async_token); skip!(node.capture); v.visit_block_mut(&mut node.block); @@ -1479,9 +1470,7 @@ pub fn visit_expr_await_mut(v: &mut V, node: &mut crate::ExprAwait) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_expr_mut(&mut *node.base); skip!(node.dot_token); skip!(node.await_token); @@ -1492,9 +1481,7 @@ pub fn visit_expr_binary_mut(v: &mut V, node: &mut crate::ExprBinary) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_expr_mut(&mut *node.left); v.visit_bin_op_mut(&mut node.op); v.visit_expr_mut(&mut *node.right); @@ -1505,9 +1492,7 @@ pub fn visit_expr_block_mut(v: &mut V, node: &mut crate::ExprBlock) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.label { v.visit_label_mut(it); } @@ -1519,9 +1504,7 @@ pub fn visit_expr_break_mut(v: &mut V, node: &mut crate::ExprBreak) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.break_token); if let Some(it) = &mut node.label { v.visit_lifetime_mut(it); @@ -1536,9 +1519,7 @@ pub fn visit_expr_call_mut(v: &mut V, node: &mut crate::ExprCall) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_expr_mut(&mut *node.func); skip!(node.paren_token); for mut el in Punctuated::pairs_mut(&mut node.args) { @@ -1552,9 +1533,7 @@ pub fn visit_expr_cast_mut(v: &mut V, node: &mut crate::ExprCast) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_expr_mut(&mut *node.expr); skip!(node.as_token); v.visit_type_mut(&mut *node.ty); @@ -1565,9 +1544,7 @@ pub fn visit_expr_closure_mut(v: &mut V, node: &mut crate::ExprClosure) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.lifetimes { v.visit_bound_lifetimes_mut(it); } @@ -1590,9 +1567,7 @@ pub fn visit_expr_const_mut(v: &mut V, node: &mut crate::ExprConst) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.const_token); v.visit_block_mut(&mut node.block); } @@ -1602,9 +1577,7 @@ pub fn visit_expr_continue_mut(v: &mut V, node: &mut crate::ExprContinue) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.continue_token); if let Some(it) = &mut node.label { v.visit_lifetime_mut(it); @@ -1616,9 +1589,7 @@ pub fn visit_expr_field_mut(v: &mut V, node: &mut crate::ExprField) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_expr_mut(&mut *node.base); skip!(node.dot_token); v.visit_member_mut(&mut node.member); @@ -1629,9 +1600,7 @@ pub fn visit_expr_for_loop_mut(v: &mut V, node: &mut crate::ExprForLoop) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.label { v.visit_label_mut(it); } @@ -1647,9 +1616,7 @@ pub fn visit_expr_group_mut(v: &mut V, node: &mut crate::ExprGroup) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.group_token); v.visit_expr_mut(&mut *node.expr); } @@ -1659,9 +1626,7 @@ pub fn visit_expr_if_mut(v: &mut V, node: &mut crate::ExprIf) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.if_token); v.visit_expr_mut(&mut *node.cond); v.visit_block_mut(&mut node.then_branch); @@ -1676,9 +1641,7 @@ pub fn visit_expr_index_mut(v: &mut V, node: &mut crate::ExprIndex) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_expr_mut(&mut *node.expr); skip!(node.bracket_token); v.visit_expr_mut(&mut *node.index); @@ -1689,9 +1652,7 @@ pub fn visit_expr_infer_mut(v: &mut V, node: &mut crate::ExprInfer) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.underscore_token); } #[cfg(feature = "full")] @@ -1700,9 +1661,7 @@ pub fn visit_expr_let_mut(v: &mut V, node: &mut crate::ExprLet) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.let_token); v.visit_pat_mut(&mut *node.pat); skip!(node.eq_token); @@ -1714,9 +1673,7 @@ pub fn visit_expr_lit_mut(v: &mut V, node: &mut crate::ExprLit) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_lit_mut(&mut node.lit); } #[cfg(feature = "full")] @@ -1725,9 +1682,7 @@ pub fn visit_expr_loop_mut(v: &mut V, node: &mut crate::ExprLoop) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.label { v.visit_label_mut(it); } @@ -1740,9 +1695,7 @@ pub fn visit_expr_macro_mut(v: &mut V, node: &mut crate::ExprMacro) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_macro_mut(&mut node.mac); } #[cfg(feature = "full")] @@ -1751,9 +1704,7 @@ pub fn visit_expr_match_mut(v: &mut V, node: &mut crate::ExprMatch) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.match_token); v.visit_expr_mut(&mut *node.expr); skip!(node.brace_token); @@ -1767,9 +1718,7 @@ pub fn visit_expr_method_call_mut(v: &mut V, node: &mut crate::ExprMethodCall where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_expr_mut(&mut *node.receiver); skip!(node.dot_token); v.visit_ident_mut(&mut node.method); @@ -1788,9 +1737,7 @@ pub fn visit_expr_paren_mut(v: &mut V, node: &mut crate::ExprParen) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.paren_token); v.visit_expr_mut(&mut *node.expr); } @@ -1800,9 +1747,7 @@ pub fn visit_expr_path_mut(v: &mut V, node: &mut crate::ExprPath) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.qself { v.visit_qself_mut(it); } @@ -1814,9 +1759,7 @@ pub fn visit_expr_range_mut(v: &mut V, node: &mut crate::ExprRange) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.start { v.visit_expr_mut(&mut **it); } @@ -1831,9 +1774,7 @@ pub fn visit_expr_raw_addr_mut(v: &mut V, node: &mut crate::ExprRawAddr) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.and_token); skip!(node.raw); v.visit_pointer_mutability_mut(&mut node.mutability); @@ -1845,9 +1786,7 @@ pub fn visit_expr_reference_mut(v: &mut V, node: &mut crate::ExprReference) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.and_token); skip!(node.mutability); v.visit_expr_mut(&mut *node.expr); @@ -1858,9 +1797,7 @@ pub fn visit_expr_repeat_mut(v: &mut V, node: &mut crate::ExprRepeat) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.bracket_token); v.visit_expr_mut(&mut *node.expr); skip!(node.semi_token); @@ -1872,9 +1809,7 @@ pub fn visit_expr_return_mut(v: &mut V, node: &mut crate::ExprReturn) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.return_token); if let Some(it) = &mut node.expr { v.visit_expr_mut(&mut **it); @@ -1886,9 +1821,7 @@ pub fn visit_expr_struct_mut(v: &mut V, node: &mut crate::ExprStruct) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.qself { v.visit_qself_mut(it); } @@ -1909,9 +1842,7 @@ pub fn visit_expr_try_mut(v: &mut V, node: &mut crate::ExprTry) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_expr_mut(&mut *node.expr); skip!(node.question_token); } @@ -1921,9 +1852,7 @@ pub fn visit_expr_try_block_mut(v: &mut V, node: &mut crate::ExprTryBlock) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.try_token); v.visit_block_mut(&mut node.block); } @@ -1933,9 +1862,7 @@ pub fn visit_expr_tuple_mut(v: &mut V, node: &mut crate::ExprTuple) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.paren_token); for mut el in Punctuated::pairs_mut(&mut node.elems) { let it = el.value_mut(); @@ -1948,9 +1875,7 @@ pub fn visit_expr_unary_mut(v: &mut V, node: &mut crate::ExprUnary) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_un_op_mut(&mut node.op); v.visit_expr_mut(&mut *node.expr); } @@ -1960,9 +1885,7 @@ pub fn visit_expr_unsafe_mut(v: &mut V, node: &mut crate::ExprUnsafe) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.unsafe_token); v.visit_block_mut(&mut node.block); } @@ -1972,9 +1895,7 @@ pub fn visit_expr_while_mut(v: &mut V, node: &mut crate::ExprWhile) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.label { v.visit_label_mut(it); } @@ -1988,9 +1909,7 @@ pub fn visit_expr_yield_mut(v: &mut V, node: &mut crate::ExprYield) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.yield_token); if let Some(it) = &mut node.expr { v.visit_expr_mut(&mut **it); @@ -2002,9 +1921,7 @@ pub fn visit_field_mut(v: &mut V, node: &mut crate::Field) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); v.visit_field_mutability_mut(&mut node.mutability); if let Some(it) = &mut node.ident { @@ -2029,9 +1946,7 @@ pub fn visit_field_pat_mut(v: &mut V, node: &mut crate::FieldPat) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_member_mut(&mut node.member); skip!(node.colon_token); v.visit_pat_mut(&mut *node.pat); @@ -2042,9 +1957,7 @@ pub fn visit_field_value_mut(v: &mut V, node: &mut crate::FieldValue) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_member_mut(&mut node.member); skip!(node.colon_token); v.visit_expr_mut(&mut node.expr); @@ -2096,9 +2009,7 @@ where V: VisitMut + ?Sized, { skip!(node.shebang); - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); for it in &mut node.items { v.visit_item_mut(it); } @@ -2148,9 +2059,7 @@ pub fn visit_foreign_item_fn_mut(v: &mut V, node: &mut crate::ForeignItemFn) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); v.visit_signature_mut(&mut node.sig); skip!(node.semi_token); @@ -2161,9 +2070,7 @@ pub fn visit_foreign_item_macro_mut(v: &mut V, node: &mut crate::ForeignItemM where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_macro_mut(&mut node.mac); skip!(node.semi_token); } @@ -2173,9 +2080,7 @@ pub fn visit_foreign_item_static_mut(v: &mut V, node: &mut crate::ForeignItem where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.static_token); v.visit_static_mutability_mut(&mut node.mutability); @@ -2190,9 +2095,7 @@ pub fn visit_foreign_item_type_mut(v: &mut V, node: &mut crate::ForeignItemTy where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.type_token); v.visit_ident_mut(&mut node.ident); @@ -2298,9 +2201,7 @@ pub fn visit_impl_item_const_mut(v: &mut V, node: &mut crate::ImplItemConst) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.defaultness); skip!(node.const_token); @@ -2318,9 +2219,7 @@ pub fn visit_impl_item_fn_mut(v: &mut V, node: &mut crate::ImplItemFn) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.defaultness); v.visit_signature_mut(&mut node.sig); @@ -2332,9 +2231,7 @@ pub fn visit_impl_item_macro_mut(v: &mut V, node: &mut crate::ImplItemMacro) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_macro_mut(&mut node.mac); skip!(node.semi_token); } @@ -2344,9 +2241,7 @@ pub fn visit_impl_item_type_mut(v: &mut V, node: &mut crate::ImplItemType) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.defaultness); skip!(node.type_token); @@ -2436,9 +2331,7 @@ pub fn visit_item_const_mut(v: &mut V, node: &mut crate::ItemConst) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.const_token); v.visit_ident_mut(&mut node.ident); @@ -2455,9 +2348,7 @@ pub fn visit_item_enum_mut(v: &mut V, node: &mut crate::ItemEnum) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.enum_token); v.visit_ident_mut(&mut node.ident); @@ -2474,9 +2365,7 @@ pub fn visit_item_extern_crate_mut(v: &mut V, node: &mut crate::ItemExternCra where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.extern_token); skip!(node.crate_token); @@ -2493,9 +2382,7 @@ pub fn visit_item_fn_mut(v: &mut V, node: &mut crate::ItemFn) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); v.visit_signature_mut(&mut node.sig); v.visit_block_mut(&mut *node.block); @@ -2506,9 +2393,7 @@ pub fn visit_item_foreign_mod_mut(v: &mut V, node: &mut crate::ItemForeignMod where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.unsafety); v.visit_abi_mut(&mut node.abi); skip!(node.brace_token); @@ -2522,9 +2407,7 @@ pub fn visit_item_impl_mut(v: &mut V, node: &mut crate::ItemImpl) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.defaultness); skip!(node.unsafety); skip!(node.impl_token); @@ -2546,9 +2429,7 @@ pub fn visit_item_macro_mut(v: &mut V, node: &mut crate::ItemMacro) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.ident { v.visit_ident_mut(it); } @@ -2561,9 +2442,7 @@ pub fn visit_item_mod_mut(v: &mut V, node: &mut crate::ItemMod) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.unsafety); skip!(node.mod_token); @@ -2582,9 +2461,7 @@ pub fn visit_item_static_mut(v: &mut V, node: &mut crate::ItemStatic) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.static_token); v.visit_static_mutability_mut(&mut node.mutability); @@ -2601,9 +2478,7 @@ pub fn visit_item_struct_mut(v: &mut V, node: &mut crate::ItemStruct) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.struct_token); v.visit_ident_mut(&mut node.ident); @@ -2617,9 +2492,7 @@ pub fn visit_item_trait_mut(v: &mut V, node: &mut crate::ItemTrait) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.unsafety); skip!(node.auto_token); @@ -2645,9 +2518,7 @@ pub fn visit_item_trait_alias_mut(v: &mut V, node: &mut crate::ItemTraitAlias where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.trait_token); v.visit_ident_mut(&mut node.ident); @@ -2665,9 +2536,7 @@ pub fn visit_item_type_mut(v: &mut V, node: &mut crate::ItemType) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.type_token); v.visit_ident_mut(&mut node.ident); @@ -2682,9 +2551,7 @@ pub fn visit_item_union_mut(v: &mut V, node: &mut crate::ItemUnion) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.union_token); v.visit_ident_mut(&mut node.ident); @@ -2697,9 +2564,7 @@ pub fn visit_item_use_mut(v: &mut V, node: &mut crate::ItemUse) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_visibility_mut(&mut node.vis); skip!(node.use_token); skip!(node.leading_colon); @@ -2728,9 +2593,7 @@ pub fn visit_lifetime_param_mut(v: &mut V, node: &mut crate::LifetimeParam) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_lifetime_mut(&mut node.lifetime); skip!(node.colon_token); for mut el in Punctuated::pairs_mut(&mut node.bounds) { @@ -2813,9 +2676,7 @@ pub fn visit_local_mut(v: &mut V, node: &mut crate::Local) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.let_token); v.visit_pat_mut(&mut node.pat); if let Some(it) = &mut node.init { @@ -3000,9 +2861,7 @@ pub fn visit_pat_ident_mut(v: &mut V, node: &mut crate::PatIdent) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.by_ref); skip!(node.mutability); v.visit_ident_mut(&mut node.ident); @@ -3017,9 +2876,7 @@ pub fn visit_pat_or_mut(v: &mut V, node: &mut crate::PatOr) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.leading_vert); for mut el in Punctuated::pairs_mut(&mut node.cases) { let it = el.value_mut(); @@ -3032,9 +2889,7 @@ pub fn visit_pat_paren_mut(v: &mut V, node: &mut crate::PatParen) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.paren_token); v.visit_pat_mut(&mut *node.pat); } @@ -3044,9 +2899,7 @@ pub fn visit_pat_reference_mut(v: &mut V, node: &mut crate::PatReference) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.and_token); skip!(node.mutability); v.visit_pat_mut(&mut *node.pat); @@ -3057,9 +2910,7 @@ pub fn visit_pat_rest_mut(v: &mut V, node: &mut crate::PatRest) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.dot2_token); } #[cfg(feature = "full")] @@ -3068,9 +2919,7 @@ pub fn visit_pat_slice_mut(v: &mut V, node: &mut crate::PatSlice) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.bracket_token); for mut el in Punctuated::pairs_mut(&mut node.elems) { let it = el.value_mut(); @@ -3083,9 +2932,7 @@ pub fn visit_pat_struct_mut(v: &mut V, node: &mut crate::PatStruct) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.qself { v.visit_qself_mut(it); } @@ -3105,9 +2952,7 @@ pub fn visit_pat_tuple_mut(v: &mut V, node: &mut crate::PatTuple) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.paren_token); for mut el in Punctuated::pairs_mut(&mut node.elems) { let it = el.value_mut(); @@ -3120,9 +2965,7 @@ pub fn visit_pat_tuple_struct_mut(v: &mut V, node: &mut crate::PatTupleStruct where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.qself { v.visit_qself_mut(it); } @@ -3139,9 +2982,7 @@ pub fn visit_pat_type_mut(v: &mut V, node: &mut crate::PatType) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_pat_mut(&mut *node.pat); skip!(node.colon_token); v.visit_type_mut(&mut *node.ty); @@ -3152,9 +2993,7 @@ pub fn visit_pat_wild_mut(v: &mut V, node: &mut crate::PatWild) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.underscore_token); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3285,9 +3124,7 @@ pub fn visit_receiver_mut(v: &mut V, node: &mut crate::Receiver) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.reference { skip!((it).0); if let Some(it) = &mut (it).1 { @@ -3383,9 +3220,7 @@ pub fn visit_stmt_macro_mut(v: &mut V, node: &mut crate::StmtMacro) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_macro_mut(&mut node.mac); skip!(node.semi_token); } @@ -3445,9 +3280,7 @@ pub fn visit_trait_item_const_mut(v: &mut V, node: &mut crate::TraitItemConst where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.const_token); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); @@ -3465,9 +3298,7 @@ pub fn visit_trait_item_fn_mut(v: &mut V, node: &mut crate::TraitItemFn) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_signature_mut(&mut node.sig); if let Some(it) = &mut node.default { v.visit_block_mut(it); @@ -3480,9 +3311,7 @@ pub fn visit_trait_item_macro_mut(v: &mut V, node: &mut crate::TraitItemMacro where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_macro_mut(&mut node.mac); skip!(node.semi_token); } @@ -3492,9 +3321,7 @@ pub fn visit_trait_item_type_mut(v: &mut V, node: &mut crate::TraitItemType) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); skip!(node.type_token); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); @@ -3649,9 +3476,7 @@ pub fn visit_type_param_mut(v: &mut V, node: &mut crate::TypeParam) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_ident_mut(&mut node.ident); skip!(node.colon_token); for mut el in Punctuated::pairs_mut(&mut node.bounds) { @@ -3857,9 +3682,7 @@ pub fn visit_variadic_mut(v: &mut V, node: &mut crate::Variadic) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); if let Some(it) = &mut node.pat { v.visit_pat_mut(&mut *(it).0); skip!((it).1); @@ -3873,9 +3696,7 @@ pub fn visit_variant_mut(v: &mut V, node: &mut crate::Variant) where V: VisitMut + ?Sized, { - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } + v.visit_attributes_mut(&mut node.attrs); v.visit_ident_mut(&mut node.ident); v.visit_fields_mut(&mut node.fields); if let Some(it) = &mut node.discriminant {