From 7681951826a0f04f650c461ab2b8db7a62f72406 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 20 Oct 2024 09:36:01 -0700 Subject: [PATCH] Add Fold and VisitMut methods for Vec --- codegen/src/fold.rs | 22 ++- codegen/src/visit_mut.rs | 30 +++- src/gen/fold.rs | 189 ++++++++++---------- src/gen/visit_mut.rs | 377 ++++++++++----------------------------- 4 files changed, 235 insertions(+), 383 deletions(-) diff --git a/codegen/src/fold.rs b/codegen/src/fold.rs index 39a0d8bc60..bd52b21924 100644 --- a/codegen/src/fold.rs +++ b/codegen/src/fold.rs @@ -32,10 +32,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 +220,14 @@ fn node(traits: &mut TokenStream, impls: &mut TokenStream, s: &Node, defs: &Defi #fold_impl } }); + + if s.ident == "Attribute" { + traits.extend(quote! { + 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..e0b8fc83ed 100644 --- a/codegen/src/visit_mut.rs +++ b/codegen/src/visit_mut.rs @@ -36,14 +36,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 +199,16 @@ fn node(traits: &mut TokenStream, impls: &mut TokenStream, s: &Node, defs: &Defi #visit_mut_impl } }); + + if s.ident == "Attribute" { + traits.extend(quote! { + 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..aff567a2dd 100644 --- a/src/gen/fold.rs +++ b/src/gen/fold.rs @@ -63,6 +63,9 @@ pub trait Fold { fn fold_attribute(&mut self, i: crate::Attribute) -> crate::Attribute { fold_attribute(self, i) } + 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 { @@ -1046,7 +1049,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 +1114,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 +1126,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 +1221,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 +1301,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 +1432,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 +1444,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 +1457,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 +1470,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 +1483,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 +1496,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 +1508,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 +1521,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 +1534,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 +1547,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 +1567,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 +1579,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 +1591,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 +1604,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 +1620,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 +1632,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 +1647,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 +1660,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 +1671,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 +1685,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 +1696,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 +1709,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 +1720,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 +1737,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 +1754,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 +1766,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 +1778,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 +1791,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 +1808,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 +1821,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 +1835,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 +1847,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 +1863,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 +1878,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 +1890,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 +1902,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 +1914,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 +1926,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 +1940,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 +1952,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 +1980,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 +1993,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 +2048,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 +2101,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 +2117,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 +2132,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 +2152,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 +2262,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 +2282,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 +2299,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 +2314,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 +2397,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 +2416,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 +2435,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 +2451,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 +2467,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 +2481,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 +2499,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 +2512,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 +2528,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 +2547,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 +2563,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 +2591,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 +2608,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 +2625,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 +2640,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 +2678,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 +2781,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 +2944,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 +2958,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 +2970,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 +2982,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 +2995,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 +3006,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 +3018,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 +3033,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 +3048,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 +3062,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 +3075,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 +3223,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 +3311,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 +3377,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 +3394,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 +3410,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 +3425,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 +3575,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 +3794,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 +3807,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..01e6419b05 100644 --- a/src/gen/visit_mut.rs +++ b/src/gen/visit_mut.rs @@ -65,6 +65,11 @@ pub trait VisitMut { fn visit_attribute_mut(&mut self, i: &mut crate::Attribute) { visit_attribute_mut(self, i); } + 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) { @@ -979,9 +984,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 +1050,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 +1063,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 +1210,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 +1292,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 +1433,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 +1446,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 +1457,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 +1468,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 +1479,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 +1490,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 +1502,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 +1517,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 +1531,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 +1542,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 +1565,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 +1575,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 +1587,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 +1598,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 +1614,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 +1624,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 +1639,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 +1650,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 +1659,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 +1671,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 +1680,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 +1693,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 +1702,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 +1716,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 +1735,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 +1745,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 +1757,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 +1772,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 +1784,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 +1795,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 +1807,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 +1819,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 +1840,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 +1850,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 +1860,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 +1873,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 +1883,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 +1893,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 +1907,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 +1919,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 +1944,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 +1955,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 +2007,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 +2057,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 +2068,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 +2078,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 +2093,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 +2199,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 +2217,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 +2229,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 +2239,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 +2329,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 +2346,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 +2363,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 +2380,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 +2391,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 +2405,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 +2427,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 +2440,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 +2459,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 +2476,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 +2490,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 +2516,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 +2534,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 +2549,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 +2562,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 +2591,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 +2674,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 +2859,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 +2874,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 +2887,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 +2897,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 +2908,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 +2917,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 +2930,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 +2950,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 +2963,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 +2980,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 +2991,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 +3122,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 +3218,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 +3278,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 +3296,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 +3309,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 +3319,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 +3474,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 +3680,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 +3694,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 {