]>
Commit | Line | Data |
---|---|---|
e74abb32 XL |
1 | // This file is @generated by syn-internal-codegen. |
2 | // It is not intended for manual editing. | |
3 | ||
4 | #![allow(unreachable_code, unused_variables)] | |
f035d41b | 5 | #![allow(clippy::match_wildcard_for_single_variants)] |
e74abb32 XL |
6 | #[cfg(any(feature = "full", feature = "derive"))] |
7 | use crate::gen::helper::fold::*; | |
8 | #[cfg(any(feature = "full", feature = "derive"))] | |
9 | use crate::token::{Brace, Bracket, Group, Paren}; | |
10 | use crate::*; | |
11 | use proc_macro2::Span; | |
12 | #[cfg(feature = "full")] | |
13 | macro_rules! full { | |
14 | ($e:expr) => { | |
15 | $e | |
16 | }; | |
17 | } | |
18 | #[cfg(all(feature = "derive", not(feature = "full")))] | |
19 | macro_rules! full { | |
20 | ($e:expr) => { | |
21 | unreachable!() | |
22 | }; | |
23 | } | |
24 | /// Syntax tree traversal to transform the nodes of an owned syntax tree. | |
25 | /// | |
26 | /// See the [module documentation] for details. | |
27 | /// | |
28 | /// [module documentation]: self | |
29 | /// | |
f035d41b | 30 | /// *This trait is available only if Syn is built with the `"fold"` feature.* |
e74abb32 XL |
31 | pub trait Fold { |
32 | #[cfg(any(feature = "derive", feature = "full"))] | |
33 | fn fold_abi(&mut self, i: Abi) -> Abi { | |
34 | fold_abi(self, i) | |
35 | } | |
36 | #[cfg(any(feature = "derive", feature = "full"))] | |
37 | fn fold_angle_bracketed_generic_arguments( | |
38 | &mut self, | |
39 | i: AngleBracketedGenericArguments, | |
40 | ) -> AngleBracketedGenericArguments { | |
41 | fold_angle_bracketed_generic_arguments(self, i) | |
42 | } | |
43 | #[cfg(feature = "full")] | |
44 | fn fold_arm(&mut self, i: Arm) -> Arm { | |
45 | fold_arm(self, i) | |
46 | } | |
47 | #[cfg(any(feature = "derive", feature = "full"))] | |
48 | fn fold_attr_style(&mut self, i: AttrStyle) -> AttrStyle { | |
49 | fold_attr_style(self, i) | |
50 | } | |
51 | #[cfg(any(feature = "derive", feature = "full"))] | |
52 | fn fold_attribute(&mut self, i: Attribute) -> Attribute { | |
53 | fold_attribute(self, i) | |
54 | } | |
55 | #[cfg(any(feature = "derive", feature = "full"))] | |
56 | fn fold_bare_fn_arg(&mut self, i: BareFnArg) -> BareFnArg { | |
57 | fold_bare_fn_arg(self, i) | |
58 | } | |
59 | #[cfg(any(feature = "derive", feature = "full"))] | |
60 | fn fold_bin_op(&mut self, i: BinOp) -> BinOp { | |
61 | fold_bin_op(self, i) | |
62 | } | |
63 | #[cfg(any(feature = "derive", feature = "full"))] | |
64 | fn fold_binding(&mut self, i: Binding) -> Binding { | |
65 | fold_binding(self, i) | |
66 | } | |
67 | #[cfg(feature = "full")] | |
68 | fn fold_block(&mut self, i: Block) -> Block { | |
69 | fold_block(self, i) | |
70 | } | |
71 | #[cfg(any(feature = "derive", feature = "full"))] | |
72 | fn fold_bound_lifetimes(&mut self, i: BoundLifetimes) -> BoundLifetimes { | |
73 | fold_bound_lifetimes(self, i) | |
74 | } | |
75 | #[cfg(any(feature = "derive", feature = "full"))] | |
76 | fn fold_const_param(&mut self, i: ConstParam) -> ConstParam { | |
77 | fold_const_param(self, i) | |
78 | } | |
79 | #[cfg(any(feature = "derive", feature = "full"))] | |
80 | fn fold_constraint(&mut self, i: Constraint) -> Constraint { | |
81 | fold_constraint(self, i) | |
82 | } | |
83 | #[cfg(feature = "derive")] | |
84 | fn fold_data(&mut self, i: Data) -> Data { | |
85 | fold_data(self, i) | |
86 | } | |
87 | #[cfg(feature = "derive")] | |
88 | fn fold_data_enum(&mut self, i: DataEnum) -> DataEnum { | |
89 | fold_data_enum(self, i) | |
90 | } | |
91 | #[cfg(feature = "derive")] | |
92 | fn fold_data_struct(&mut self, i: DataStruct) -> DataStruct { | |
93 | fold_data_struct(self, i) | |
94 | } | |
95 | #[cfg(feature = "derive")] | |
96 | fn fold_data_union(&mut self, i: DataUnion) -> DataUnion { | |
97 | fold_data_union(self, i) | |
98 | } | |
99 | #[cfg(feature = "derive")] | |
100 | fn fold_derive_input(&mut self, i: DeriveInput) -> DeriveInput { | |
101 | fold_derive_input(self, i) | |
102 | } | |
103 | #[cfg(any(feature = "derive", feature = "full"))] | |
104 | fn fold_expr(&mut self, i: Expr) -> Expr { | |
105 | fold_expr(self, i) | |
106 | } | |
107 | #[cfg(feature = "full")] | |
108 | fn fold_expr_array(&mut self, i: ExprArray) -> ExprArray { | |
109 | fold_expr_array(self, i) | |
110 | } | |
111 | #[cfg(feature = "full")] | |
112 | fn fold_expr_assign(&mut self, i: ExprAssign) -> ExprAssign { | |
113 | fold_expr_assign(self, i) | |
114 | } | |
115 | #[cfg(feature = "full")] | |
116 | fn fold_expr_assign_op(&mut self, i: ExprAssignOp) -> ExprAssignOp { | |
117 | fold_expr_assign_op(self, i) | |
118 | } | |
119 | #[cfg(feature = "full")] | |
120 | fn fold_expr_async(&mut self, i: ExprAsync) -> ExprAsync { | |
121 | fold_expr_async(self, i) | |
122 | } | |
123 | #[cfg(feature = "full")] | |
124 | fn fold_expr_await(&mut self, i: ExprAwait) -> ExprAwait { | |
125 | fold_expr_await(self, i) | |
126 | } | |
127 | #[cfg(any(feature = "derive", feature = "full"))] | |
128 | fn fold_expr_binary(&mut self, i: ExprBinary) -> ExprBinary { | |
129 | fold_expr_binary(self, i) | |
130 | } | |
131 | #[cfg(feature = "full")] | |
132 | fn fold_expr_block(&mut self, i: ExprBlock) -> ExprBlock { | |
133 | fold_expr_block(self, i) | |
134 | } | |
135 | #[cfg(feature = "full")] | |
136 | fn fold_expr_box(&mut self, i: ExprBox) -> ExprBox { | |
137 | fold_expr_box(self, i) | |
138 | } | |
139 | #[cfg(feature = "full")] | |
140 | fn fold_expr_break(&mut self, i: ExprBreak) -> ExprBreak { | |
141 | fold_expr_break(self, i) | |
142 | } | |
143 | #[cfg(any(feature = "derive", feature = "full"))] | |
144 | fn fold_expr_call(&mut self, i: ExprCall) -> ExprCall { | |
145 | fold_expr_call(self, i) | |
146 | } | |
147 | #[cfg(any(feature = "derive", feature = "full"))] | |
148 | fn fold_expr_cast(&mut self, i: ExprCast) -> ExprCast { | |
149 | fold_expr_cast(self, i) | |
150 | } | |
151 | #[cfg(feature = "full")] | |
152 | fn fold_expr_closure(&mut self, i: ExprClosure) -> ExprClosure { | |
153 | fold_expr_closure(self, i) | |
154 | } | |
155 | #[cfg(feature = "full")] | |
156 | fn fold_expr_continue(&mut self, i: ExprContinue) -> ExprContinue { | |
157 | fold_expr_continue(self, i) | |
158 | } | |
159 | #[cfg(any(feature = "derive", feature = "full"))] | |
160 | fn fold_expr_field(&mut self, i: ExprField) -> ExprField { | |
161 | fold_expr_field(self, i) | |
162 | } | |
163 | #[cfg(feature = "full")] | |
164 | fn fold_expr_for_loop(&mut self, i: ExprForLoop) -> ExprForLoop { | |
165 | fold_expr_for_loop(self, i) | |
166 | } | |
167 | #[cfg(feature = "full")] | |
168 | fn fold_expr_group(&mut self, i: ExprGroup) -> ExprGroup { | |
169 | fold_expr_group(self, i) | |
170 | } | |
171 | #[cfg(feature = "full")] | |
172 | fn fold_expr_if(&mut self, i: ExprIf) -> ExprIf { | |
173 | fold_expr_if(self, i) | |
174 | } | |
175 | #[cfg(any(feature = "derive", feature = "full"))] | |
176 | fn fold_expr_index(&mut self, i: ExprIndex) -> ExprIndex { | |
177 | fold_expr_index(self, i) | |
178 | } | |
179 | #[cfg(feature = "full")] | |
180 | fn fold_expr_let(&mut self, i: ExprLet) -> ExprLet { | |
181 | fold_expr_let(self, i) | |
182 | } | |
183 | #[cfg(any(feature = "derive", feature = "full"))] | |
184 | fn fold_expr_lit(&mut self, i: ExprLit) -> ExprLit { | |
185 | fold_expr_lit(self, i) | |
186 | } | |
187 | #[cfg(feature = "full")] | |
188 | fn fold_expr_loop(&mut self, i: ExprLoop) -> ExprLoop { | |
189 | fold_expr_loop(self, i) | |
190 | } | |
191 | #[cfg(feature = "full")] | |
192 | fn fold_expr_macro(&mut self, i: ExprMacro) -> ExprMacro { | |
193 | fold_expr_macro(self, i) | |
194 | } | |
195 | #[cfg(feature = "full")] | |
196 | fn fold_expr_match(&mut self, i: ExprMatch) -> ExprMatch { | |
197 | fold_expr_match(self, i) | |
198 | } | |
199 | #[cfg(feature = "full")] | |
200 | fn fold_expr_method_call(&mut self, i: ExprMethodCall) -> ExprMethodCall { | |
201 | fold_expr_method_call(self, i) | |
202 | } | |
203 | #[cfg(any(feature = "derive", feature = "full"))] | |
204 | fn fold_expr_paren(&mut self, i: ExprParen) -> ExprParen { | |
205 | fold_expr_paren(self, i) | |
206 | } | |
207 | #[cfg(any(feature = "derive", feature = "full"))] | |
208 | fn fold_expr_path(&mut self, i: ExprPath) -> ExprPath { | |
209 | fold_expr_path(self, i) | |
210 | } | |
211 | #[cfg(feature = "full")] | |
212 | fn fold_expr_range(&mut self, i: ExprRange) -> ExprRange { | |
213 | fold_expr_range(self, i) | |
214 | } | |
215 | #[cfg(feature = "full")] | |
216 | fn fold_expr_reference(&mut self, i: ExprReference) -> ExprReference { | |
217 | fold_expr_reference(self, i) | |
218 | } | |
219 | #[cfg(feature = "full")] | |
220 | fn fold_expr_repeat(&mut self, i: ExprRepeat) -> ExprRepeat { | |
221 | fold_expr_repeat(self, i) | |
222 | } | |
223 | #[cfg(feature = "full")] | |
224 | fn fold_expr_return(&mut self, i: ExprReturn) -> ExprReturn { | |
225 | fold_expr_return(self, i) | |
226 | } | |
227 | #[cfg(feature = "full")] | |
228 | fn fold_expr_struct(&mut self, i: ExprStruct) -> ExprStruct { | |
229 | fold_expr_struct(self, i) | |
230 | } | |
231 | #[cfg(feature = "full")] | |
232 | fn fold_expr_try(&mut self, i: ExprTry) -> ExprTry { | |
233 | fold_expr_try(self, i) | |
234 | } | |
235 | #[cfg(feature = "full")] | |
236 | fn fold_expr_try_block(&mut self, i: ExprTryBlock) -> ExprTryBlock { | |
237 | fold_expr_try_block(self, i) | |
238 | } | |
239 | #[cfg(feature = "full")] | |
240 | fn fold_expr_tuple(&mut self, i: ExprTuple) -> ExprTuple { | |
241 | fold_expr_tuple(self, i) | |
242 | } | |
243 | #[cfg(feature = "full")] | |
244 | fn fold_expr_type(&mut self, i: ExprType) -> ExprType { | |
245 | fold_expr_type(self, i) | |
246 | } | |
247 | #[cfg(any(feature = "derive", feature = "full"))] | |
248 | fn fold_expr_unary(&mut self, i: ExprUnary) -> ExprUnary { | |
249 | fold_expr_unary(self, i) | |
250 | } | |
251 | #[cfg(feature = "full")] | |
252 | fn fold_expr_unsafe(&mut self, i: ExprUnsafe) -> ExprUnsafe { | |
253 | fold_expr_unsafe(self, i) | |
254 | } | |
255 | #[cfg(feature = "full")] | |
256 | fn fold_expr_while(&mut self, i: ExprWhile) -> ExprWhile { | |
257 | fold_expr_while(self, i) | |
258 | } | |
259 | #[cfg(feature = "full")] | |
260 | fn fold_expr_yield(&mut self, i: ExprYield) -> ExprYield { | |
261 | fold_expr_yield(self, i) | |
262 | } | |
263 | #[cfg(any(feature = "derive", feature = "full"))] | |
264 | fn fold_field(&mut self, i: Field) -> Field { | |
265 | fold_field(self, i) | |
266 | } | |
267 | #[cfg(feature = "full")] | |
268 | fn fold_field_pat(&mut self, i: FieldPat) -> FieldPat { | |
269 | fold_field_pat(self, i) | |
270 | } | |
271 | #[cfg(feature = "full")] | |
272 | fn fold_field_value(&mut self, i: FieldValue) -> FieldValue { | |
273 | fold_field_value(self, i) | |
274 | } | |
275 | #[cfg(any(feature = "derive", feature = "full"))] | |
276 | fn fold_fields(&mut self, i: Fields) -> Fields { | |
277 | fold_fields(self, i) | |
278 | } | |
279 | #[cfg(any(feature = "derive", feature = "full"))] | |
280 | fn fold_fields_named(&mut self, i: FieldsNamed) -> FieldsNamed { | |
281 | fold_fields_named(self, i) | |
282 | } | |
283 | #[cfg(any(feature = "derive", feature = "full"))] | |
284 | fn fold_fields_unnamed(&mut self, i: FieldsUnnamed) -> FieldsUnnamed { | |
285 | fold_fields_unnamed(self, i) | |
286 | } | |
287 | #[cfg(feature = "full")] | |
288 | fn fold_file(&mut self, i: File) -> File { | |
289 | fold_file(self, i) | |
290 | } | |
291 | #[cfg(feature = "full")] | |
292 | fn fold_fn_arg(&mut self, i: FnArg) -> FnArg { | |
293 | fold_fn_arg(self, i) | |
294 | } | |
295 | #[cfg(feature = "full")] | |
296 | fn fold_foreign_item(&mut self, i: ForeignItem) -> ForeignItem { | |
297 | fold_foreign_item(self, i) | |
298 | } | |
299 | #[cfg(feature = "full")] | |
300 | fn fold_foreign_item_fn(&mut self, i: ForeignItemFn) -> ForeignItemFn { | |
301 | fold_foreign_item_fn(self, i) | |
302 | } | |
303 | #[cfg(feature = "full")] | |
304 | fn fold_foreign_item_macro(&mut self, i: ForeignItemMacro) -> ForeignItemMacro { | |
305 | fold_foreign_item_macro(self, i) | |
306 | } | |
307 | #[cfg(feature = "full")] | |
308 | fn fold_foreign_item_static(&mut self, i: ForeignItemStatic) -> ForeignItemStatic { | |
309 | fold_foreign_item_static(self, i) | |
310 | } | |
311 | #[cfg(feature = "full")] | |
312 | fn fold_foreign_item_type(&mut self, i: ForeignItemType) -> ForeignItemType { | |
313 | fold_foreign_item_type(self, i) | |
314 | } | |
315 | #[cfg(any(feature = "derive", feature = "full"))] | |
316 | fn fold_generic_argument(&mut self, i: GenericArgument) -> GenericArgument { | |
317 | fold_generic_argument(self, i) | |
318 | } | |
319 | #[cfg(feature = "full")] | |
320 | fn fold_generic_method_argument(&mut self, i: GenericMethodArgument) -> GenericMethodArgument { | |
321 | fold_generic_method_argument(self, i) | |
322 | } | |
323 | #[cfg(any(feature = "derive", feature = "full"))] | |
324 | fn fold_generic_param(&mut self, i: GenericParam) -> GenericParam { | |
325 | fold_generic_param(self, i) | |
326 | } | |
327 | #[cfg(any(feature = "derive", feature = "full"))] | |
328 | fn fold_generics(&mut self, i: Generics) -> Generics { | |
329 | fold_generics(self, i) | |
330 | } | |
331 | fn fold_ident(&mut self, i: Ident) -> Ident { | |
332 | fold_ident(self, i) | |
333 | } | |
334 | #[cfg(feature = "full")] | |
335 | fn fold_impl_item(&mut self, i: ImplItem) -> ImplItem { | |
336 | fold_impl_item(self, i) | |
337 | } | |
338 | #[cfg(feature = "full")] | |
339 | fn fold_impl_item_const(&mut self, i: ImplItemConst) -> ImplItemConst { | |
340 | fold_impl_item_const(self, i) | |
341 | } | |
342 | #[cfg(feature = "full")] | |
343 | fn fold_impl_item_macro(&mut self, i: ImplItemMacro) -> ImplItemMacro { | |
344 | fold_impl_item_macro(self, i) | |
345 | } | |
346 | #[cfg(feature = "full")] | |
347 | fn fold_impl_item_method(&mut self, i: ImplItemMethod) -> ImplItemMethod { | |
348 | fold_impl_item_method(self, i) | |
349 | } | |
350 | #[cfg(feature = "full")] | |
351 | fn fold_impl_item_type(&mut self, i: ImplItemType) -> ImplItemType { | |
352 | fold_impl_item_type(self, i) | |
353 | } | |
354 | #[cfg(any(feature = "derive", feature = "full"))] | |
355 | fn fold_index(&mut self, i: Index) -> Index { | |
356 | fold_index(self, i) | |
357 | } | |
358 | #[cfg(feature = "full")] | |
359 | fn fold_item(&mut self, i: Item) -> Item { | |
360 | fold_item(self, i) | |
361 | } | |
362 | #[cfg(feature = "full")] | |
363 | fn fold_item_const(&mut self, i: ItemConst) -> ItemConst { | |
364 | fold_item_const(self, i) | |
365 | } | |
366 | #[cfg(feature = "full")] | |
367 | fn fold_item_enum(&mut self, i: ItemEnum) -> ItemEnum { | |
368 | fold_item_enum(self, i) | |
369 | } | |
370 | #[cfg(feature = "full")] | |
371 | fn fold_item_extern_crate(&mut self, i: ItemExternCrate) -> ItemExternCrate { | |
372 | fold_item_extern_crate(self, i) | |
373 | } | |
374 | #[cfg(feature = "full")] | |
375 | fn fold_item_fn(&mut self, i: ItemFn) -> ItemFn { | |
376 | fold_item_fn(self, i) | |
377 | } | |
378 | #[cfg(feature = "full")] | |
379 | fn fold_item_foreign_mod(&mut self, i: ItemForeignMod) -> ItemForeignMod { | |
380 | fold_item_foreign_mod(self, i) | |
381 | } | |
382 | #[cfg(feature = "full")] | |
383 | fn fold_item_impl(&mut self, i: ItemImpl) -> ItemImpl { | |
384 | fold_item_impl(self, i) | |
385 | } | |
386 | #[cfg(feature = "full")] | |
387 | fn fold_item_macro(&mut self, i: ItemMacro) -> ItemMacro { | |
388 | fold_item_macro(self, i) | |
389 | } | |
390 | #[cfg(feature = "full")] | |
391 | fn fold_item_macro2(&mut self, i: ItemMacro2) -> ItemMacro2 { | |
392 | fold_item_macro2(self, i) | |
393 | } | |
394 | #[cfg(feature = "full")] | |
395 | fn fold_item_mod(&mut self, i: ItemMod) -> ItemMod { | |
396 | fold_item_mod(self, i) | |
397 | } | |
398 | #[cfg(feature = "full")] | |
399 | fn fold_item_static(&mut self, i: ItemStatic) -> ItemStatic { | |
400 | fold_item_static(self, i) | |
401 | } | |
402 | #[cfg(feature = "full")] | |
403 | fn fold_item_struct(&mut self, i: ItemStruct) -> ItemStruct { | |
404 | fold_item_struct(self, i) | |
405 | } | |
406 | #[cfg(feature = "full")] | |
407 | fn fold_item_trait(&mut self, i: ItemTrait) -> ItemTrait { | |
408 | fold_item_trait(self, i) | |
409 | } | |
410 | #[cfg(feature = "full")] | |
411 | fn fold_item_trait_alias(&mut self, i: ItemTraitAlias) -> ItemTraitAlias { | |
412 | fold_item_trait_alias(self, i) | |
413 | } | |
414 | #[cfg(feature = "full")] | |
415 | fn fold_item_type(&mut self, i: ItemType) -> ItemType { | |
416 | fold_item_type(self, i) | |
417 | } | |
418 | #[cfg(feature = "full")] | |
419 | fn fold_item_union(&mut self, i: ItemUnion) -> ItemUnion { | |
420 | fold_item_union(self, i) | |
421 | } | |
422 | #[cfg(feature = "full")] | |
423 | fn fold_item_use(&mut self, i: ItemUse) -> ItemUse { | |
424 | fold_item_use(self, i) | |
425 | } | |
426 | #[cfg(feature = "full")] | |
427 | fn fold_label(&mut self, i: Label) -> Label { | |
428 | fold_label(self, i) | |
429 | } | |
430 | fn fold_lifetime(&mut self, i: Lifetime) -> Lifetime { | |
431 | fold_lifetime(self, i) | |
432 | } | |
433 | #[cfg(any(feature = "derive", feature = "full"))] | |
434 | fn fold_lifetime_def(&mut self, i: LifetimeDef) -> LifetimeDef { | |
435 | fold_lifetime_def(self, i) | |
436 | } | |
e74abb32 XL |
437 | fn fold_lit(&mut self, i: Lit) -> Lit { |
438 | fold_lit(self, i) | |
439 | } | |
e74abb32 XL |
440 | fn fold_lit_bool(&mut self, i: LitBool) -> LitBool { |
441 | fold_lit_bool(self, i) | |
442 | } | |
e74abb32 XL |
443 | fn fold_lit_byte(&mut self, i: LitByte) -> LitByte { |
444 | fold_lit_byte(self, i) | |
445 | } | |
e74abb32 XL |
446 | fn fold_lit_byte_str(&mut self, i: LitByteStr) -> LitByteStr { |
447 | fold_lit_byte_str(self, i) | |
448 | } | |
e74abb32 XL |
449 | fn fold_lit_char(&mut self, i: LitChar) -> LitChar { |
450 | fold_lit_char(self, i) | |
451 | } | |
e74abb32 XL |
452 | fn fold_lit_float(&mut self, i: LitFloat) -> LitFloat { |
453 | fold_lit_float(self, i) | |
454 | } | |
e74abb32 XL |
455 | fn fold_lit_int(&mut self, i: LitInt) -> LitInt { |
456 | fold_lit_int(self, i) | |
457 | } | |
e74abb32 XL |
458 | fn fold_lit_str(&mut self, i: LitStr) -> LitStr { |
459 | fold_lit_str(self, i) | |
460 | } | |
461 | #[cfg(feature = "full")] | |
462 | fn fold_local(&mut self, i: Local) -> Local { | |
463 | fold_local(self, i) | |
464 | } | |
465 | #[cfg(any(feature = "derive", feature = "full"))] | |
466 | fn fold_macro(&mut self, i: Macro) -> Macro { | |
467 | fold_macro(self, i) | |
468 | } | |
469 | #[cfg(any(feature = "derive", feature = "full"))] | |
470 | fn fold_macro_delimiter(&mut self, i: MacroDelimiter) -> MacroDelimiter { | |
471 | fold_macro_delimiter(self, i) | |
472 | } | |
473 | #[cfg(any(feature = "derive", feature = "full"))] | |
474 | fn fold_member(&mut self, i: Member) -> Member { | |
475 | fold_member(self, i) | |
476 | } | |
477 | #[cfg(any(feature = "derive", feature = "full"))] | |
478 | fn fold_meta(&mut self, i: Meta) -> Meta { | |
479 | fold_meta(self, i) | |
480 | } | |
481 | #[cfg(any(feature = "derive", feature = "full"))] | |
482 | fn fold_meta_list(&mut self, i: MetaList) -> MetaList { | |
483 | fold_meta_list(self, i) | |
484 | } | |
485 | #[cfg(any(feature = "derive", feature = "full"))] | |
486 | fn fold_meta_name_value(&mut self, i: MetaNameValue) -> MetaNameValue { | |
487 | fold_meta_name_value(self, i) | |
488 | } | |
489 | #[cfg(feature = "full")] | |
490 | fn fold_method_turbofish(&mut self, i: MethodTurbofish) -> MethodTurbofish { | |
491 | fold_method_turbofish(self, i) | |
492 | } | |
493 | #[cfg(any(feature = "derive", feature = "full"))] | |
494 | fn fold_nested_meta(&mut self, i: NestedMeta) -> NestedMeta { | |
495 | fold_nested_meta(self, i) | |
496 | } | |
497 | #[cfg(any(feature = "derive", feature = "full"))] | |
498 | fn fold_parenthesized_generic_arguments( | |
499 | &mut self, | |
500 | i: ParenthesizedGenericArguments, | |
501 | ) -> ParenthesizedGenericArguments { | |
502 | fold_parenthesized_generic_arguments(self, i) | |
503 | } | |
504 | #[cfg(feature = "full")] | |
505 | fn fold_pat(&mut self, i: Pat) -> Pat { | |
506 | fold_pat(self, i) | |
507 | } | |
508 | #[cfg(feature = "full")] | |
509 | fn fold_pat_box(&mut self, i: PatBox) -> PatBox { | |
510 | fold_pat_box(self, i) | |
511 | } | |
512 | #[cfg(feature = "full")] | |
513 | fn fold_pat_ident(&mut self, i: PatIdent) -> PatIdent { | |
514 | fold_pat_ident(self, i) | |
515 | } | |
516 | #[cfg(feature = "full")] | |
517 | fn fold_pat_lit(&mut self, i: PatLit) -> PatLit { | |
518 | fold_pat_lit(self, i) | |
519 | } | |
520 | #[cfg(feature = "full")] | |
521 | fn fold_pat_macro(&mut self, i: PatMacro) -> PatMacro { | |
522 | fold_pat_macro(self, i) | |
523 | } | |
524 | #[cfg(feature = "full")] | |
525 | fn fold_pat_or(&mut self, i: PatOr) -> PatOr { | |
526 | fold_pat_or(self, i) | |
527 | } | |
528 | #[cfg(feature = "full")] | |
529 | fn fold_pat_path(&mut self, i: PatPath) -> PatPath { | |
530 | fold_pat_path(self, i) | |
531 | } | |
532 | #[cfg(feature = "full")] | |
533 | fn fold_pat_range(&mut self, i: PatRange) -> PatRange { | |
534 | fold_pat_range(self, i) | |
535 | } | |
536 | #[cfg(feature = "full")] | |
537 | fn fold_pat_reference(&mut self, i: PatReference) -> PatReference { | |
538 | fold_pat_reference(self, i) | |
539 | } | |
540 | #[cfg(feature = "full")] | |
541 | fn fold_pat_rest(&mut self, i: PatRest) -> PatRest { | |
542 | fold_pat_rest(self, i) | |
543 | } | |
544 | #[cfg(feature = "full")] | |
545 | fn fold_pat_slice(&mut self, i: PatSlice) -> PatSlice { | |
546 | fold_pat_slice(self, i) | |
547 | } | |
548 | #[cfg(feature = "full")] | |
549 | fn fold_pat_struct(&mut self, i: PatStruct) -> PatStruct { | |
550 | fold_pat_struct(self, i) | |
551 | } | |
552 | #[cfg(feature = "full")] | |
553 | fn fold_pat_tuple(&mut self, i: PatTuple) -> PatTuple { | |
554 | fold_pat_tuple(self, i) | |
555 | } | |
556 | #[cfg(feature = "full")] | |
557 | fn fold_pat_tuple_struct(&mut self, i: PatTupleStruct) -> PatTupleStruct { | |
558 | fold_pat_tuple_struct(self, i) | |
559 | } | |
560 | #[cfg(feature = "full")] | |
561 | fn fold_pat_type(&mut self, i: PatType) -> PatType { | |
562 | fold_pat_type(self, i) | |
563 | } | |
564 | #[cfg(feature = "full")] | |
565 | fn fold_pat_wild(&mut self, i: PatWild) -> PatWild { | |
566 | fold_pat_wild(self, i) | |
567 | } | |
568 | #[cfg(any(feature = "derive", feature = "full"))] | |
569 | fn fold_path(&mut self, i: Path) -> Path { | |
570 | fold_path(self, i) | |
571 | } | |
572 | #[cfg(any(feature = "derive", feature = "full"))] | |
573 | fn fold_path_arguments(&mut self, i: PathArguments) -> PathArguments { | |
574 | fold_path_arguments(self, i) | |
575 | } | |
576 | #[cfg(any(feature = "derive", feature = "full"))] | |
577 | fn fold_path_segment(&mut self, i: PathSegment) -> PathSegment { | |
578 | fold_path_segment(self, i) | |
579 | } | |
580 | #[cfg(any(feature = "derive", feature = "full"))] | |
581 | fn fold_predicate_eq(&mut self, i: PredicateEq) -> PredicateEq { | |
582 | fold_predicate_eq(self, i) | |
583 | } | |
584 | #[cfg(any(feature = "derive", feature = "full"))] | |
585 | fn fold_predicate_lifetime(&mut self, i: PredicateLifetime) -> PredicateLifetime { | |
586 | fold_predicate_lifetime(self, i) | |
587 | } | |
588 | #[cfg(any(feature = "derive", feature = "full"))] | |
589 | fn fold_predicate_type(&mut self, i: PredicateType) -> PredicateType { | |
590 | fold_predicate_type(self, i) | |
591 | } | |
592 | #[cfg(any(feature = "derive", feature = "full"))] | |
593 | fn fold_qself(&mut self, i: QSelf) -> QSelf { | |
594 | fold_qself(self, i) | |
595 | } | |
596 | #[cfg(feature = "full")] | |
597 | fn fold_range_limits(&mut self, i: RangeLimits) -> RangeLimits { | |
598 | fold_range_limits(self, i) | |
599 | } | |
600 | #[cfg(feature = "full")] | |
601 | fn fold_receiver(&mut self, i: Receiver) -> Receiver { | |
602 | fold_receiver(self, i) | |
603 | } | |
604 | #[cfg(any(feature = "derive", feature = "full"))] | |
605 | fn fold_return_type(&mut self, i: ReturnType) -> ReturnType { | |
606 | fold_return_type(self, i) | |
607 | } | |
608 | #[cfg(feature = "full")] | |
609 | fn fold_signature(&mut self, i: Signature) -> Signature { | |
610 | fold_signature(self, i) | |
611 | } | |
612 | fn fold_span(&mut self, i: Span) -> Span { | |
613 | fold_span(self, i) | |
614 | } | |
615 | #[cfg(feature = "full")] | |
616 | fn fold_stmt(&mut self, i: Stmt) -> Stmt { | |
617 | fold_stmt(self, i) | |
618 | } | |
619 | #[cfg(any(feature = "derive", feature = "full"))] | |
620 | fn fold_trait_bound(&mut self, i: TraitBound) -> TraitBound { | |
621 | fold_trait_bound(self, i) | |
622 | } | |
623 | #[cfg(any(feature = "derive", feature = "full"))] | |
624 | fn fold_trait_bound_modifier(&mut self, i: TraitBoundModifier) -> TraitBoundModifier { | |
625 | fold_trait_bound_modifier(self, i) | |
626 | } | |
627 | #[cfg(feature = "full")] | |
628 | fn fold_trait_item(&mut self, i: TraitItem) -> TraitItem { | |
629 | fold_trait_item(self, i) | |
630 | } | |
631 | #[cfg(feature = "full")] | |
632 | fn fold_trait_item_const(&mut self, i: TraitItemConst) -> TraitItemConst { | |
633 | fold_trait_item_const(self, i) | |
634 | } | |
635 | #[cfg(feature = "full")] | |
636 | fn fold_trait_item_macro(&mut self, i: TraitItemMacro) -> TraitItemMacro { | |
637 | fold_trait_item_macro(self, i) | |
638 | } | |
639 | #[cfg(feature = "full")] | |
640 | fn fold_trait_item_method(&mut self, i: TraitItemMethod) -> TraitItemMethod { | |
641 | fold_trait_item_method(self, i) | |
642 | } | |
643 | #[cfg(feature = "full")] | |
644 | fn fold_trait_item_type(&mut self, i: TraitItemType) -> TraitItemType { | |
645 | fold_trait_item_type(self, i) | |
646 | } | |
647 | #[cfg(any(feature = "derive", feature = "full"))] | |
648 | fn fold_type(&mut self, i: Type) -> Type { | |
649 | fold_type(self, i) | |
650 | } | |
651 | #[cfg(any(feature = "derive", feature = "full"))] | |
652 | fn fold_type_array(&mut self, i: TypeArray) -> TypeArray { | |
653 | fold_type_array(self, i) | |
654 | } | |
655 | #[cfg(any(feature = "derive", feature = "full"))] | |
656 | fn fold_type_bare_fn(&mut self, i: TypeBareFn) -> TypeBareFn { | |
657 | fold_type_bare_fn(self, i) | |
658 | } | |
659 | #[cfg(any(feature = "derive", feature = "full"))] | |
660 | fn fold_type_group(&mut self, i: TypeGroup) -> TypeGroup { | |
661 | fold_type_group(self, i) | |
662 | } | |
663 | #[cfg(any(feature = "derive", feature = "full"))] | |
664 | fn fold_type_impl_trait(&mut self, i: TypeImplTrait) -> TypeImplTrait { | |
665 | fold_type_impl_trait(self, i) | |
666 | } | |
667 | #[cfg(any(feature = "derive", feature = "full"))] | |
668 | fn fold_type_infer(&mut self, i: TypeInfer) -> TypeInfer { | |
669 | fold_type_infer(self, i) | |
670 | } | |
671 | #[cfg(any(feature = "derive", feature = "full"))] | |
672 | fn fold_type_macro(&mut self, i: TypeMacro) -> TypeMacro { | |
673 | fold_type_macro(self, i) | |
674 | } | |
675 | #[cfg(any(feature = "derive", feature = "full"))] | |
676 | fn fold_type_never(&mut self, i: TypeNever) -> TypeNever { | |
677 | fold_type_never(self, i) | |
678 | } | |
679 | #[cfg(any(feature = "derive", feature = "full"))] | |
680 | fn fold_type_param(&mut self, i: TypeParam) -> TypeParam { | |
681 | fold_type_param(self, i) | |
682 | } | |
683 | #[cfg(any(feature = "derive", feature = "full"))] | |
684 | fn fold_type_param_bound(&mut self, i: TypeParamBound) -> TypeParamBound { | |
685 | fold_type_param_bound(self, i) | |
686 | } | |
687 | #[cfg(any(feature = "derive", feature = "full"))] | |
688 | fn fold_type_paren(&mut self, i: TypeParen) -> TypeParen { | |
689 | fold_type_paren(self, i) | |
690 | } | |
691 | #[cfg(any(feature = "derive", feature = "full"))] | |
692 | fn fold_type_path(&mut self, i: TypePath) -> TypePath { | |
693 | fold_type_path(self, i) | |
694 | } | |
695 | #[cfg(any(feature = "derive", feature = "full"))] | |
696 | fn fold_type_ptr(&mut self, i: TypePtr) -> TypePtr { | |
697 | fold_type_ptr(self, i) | |
698 | } | |
699 | #[cfg(any(feature = "derive", feature = "full"))] | |
700 | fn fold_type_reference(&mut self, i: TypeReference) -> TypeReference { | |
701 | fold_type_reference(self, i) | |
702 | } | |
703 | #[cfg(any(feature = "derive", feature = "full"))] | |
704 | fn fold_type_slice(&mut self, i: TypeSlice) -> TypeSlice { | |
705 | fold_type_slice(self, i) | |
706 | } | |
707 | #[cfg(any(feature = "derive", feature = "full"))] | |
708 | fn fold_type_trait_object(&mut self, i: TypeTraitObject) -> TypeTraitObject { | |
709 | fold_type_trait_object(self, i) | |
710 | } | |
711 | #[cfg(any(feature = "derive", feature = "full"))] | |
712 | fn fold_type_tuple(&mut self, i: TypeTuple) -> TypeTuple { | |
713 | fold_type_tuple(self, i) | |
714 | } | |
715 | #[cfg(any(feature = "derive", feature = "full"))] | |
716 | fn fold_un_op(&mut self, i: UnOp) -> UnOp { | |
717 | fold_un_op(self, i) | |
718 | } | |
719 | #[cfg(feature = "full")] | |
720 | fn fold_use_glob(&mut self, i: UseGlob) -> UseGlob { | |
721 | fold_use_glob(self, i) | |
722 | } | |
723 | #[cfg(feature = "full")] | |
724 | fn fold_use_group(&mut self, i: UseGroup) -> UseGroup { | |
725 | fold_use_group(self, i) | |
726 | } | |
727 | #[cfg(feature = "full")] | |
728 | fn fold_use_name(&mut self, i: UseName) -> UseName { | |
729 | fold_use_name(self, i) | |
730 | } | |
731 | #[cfg(feature = "full")] | |
732 | fn fold_use_path(&mut self, i: UsePath) -> UsePath { | |
733 | fold_use_path(self, i) | |
734 | } | |
735 | #[cfg(feature = "full")] | |
736 | fn fold_use_rename(&mut self, i: UseRename) -> UseRename { | |
737 | fold_use_rename(self, i) | |
738 | } | |
739 | #[cfg(feature = "full")] | |
740 | fn fold_use_tree(&mut self, i: UseTree) -> UseTree { | |
741 | fold_use_tree(self, i) | |
742 | } | |
743 | #[cfg(any(feature = "derive", feature = "full"))] | |
744 | fn fold_variadic(&mut self, i: Variadic) -> Variadic { | |
745 | fold_variadic(self, i) | |
746 | } | |
747 | #[cfg(any(feature = "derive", feature = "full"))] | |
748 | fn fold_variant(&mut self, i: Variant) -> Variant { | |
749 | fold_variant(self, i) | |
750 | } | |
751 | #[cfg(any(feature = "derive", feature = "full"))] | |
752 | fn fold_vis_crate(&mut self, i: VisCrate) -> VisCrate { | |
753 | fold_vis_crate(self, i) | |
754 | } | |
755 | #[cfg(any(feature = "derive", feature = "full"))] | |
756 | fn fold_vis_public(&mut self, i: VisPublic) -> VisPublic { | |
757 | fold_vis_public(self, i) | |
758 | } | |
759 | #[cfg(any(feature = "derive", feature = "full"))] | |
760 | fn fold_vis_restricted(&mut self, i: VisRestricted) -> VisRestricted { | |
761 | fold_vis_restricted(self, i) | |
762 | } | |
763 | #[cfg(any(feature = "derive", feature = "full"))] | |
764 | fn fold_visibility(&mut self, i: Visibility) -> Visibility { | |
765 | fold_visibility(self, i) | |
766 | } | |
767 | #[cfg(any(feature = "derive", feature = "full"))] | |
768 | fn fold_where_clause(&mut self, i: WhereClause) -> WhereClause { | |
769 | fold_where_clause(self, i) | |
770 | } | |
771 | #[cfg(any(feature = "derive", feature = "full"))] | |
772 | fn fold_where_predicate(&mut self, i: WherePredicate) -> WherePredicate { | |
773 | fold_where_predicate(self, i) | |
774 | } | |
775 | } | |
776 | #[cfg(any(feature = "derive", feature = "full"))] | |
777 | pub fn fold_abi<F>(f: &mut F, node: Abi) -> Abi | |
778 | where | |
779 | F: Fold + ?Sized, | |
780 | { | |
781 | Abi { | |
782 | extern_token: Token![extern](tokens_helper(f, &node.extern_token.span)), | |
783 | name: (node.name).map(|it| f.fold_lit_str(it)), | |
784 | } | |
785 | } | |
786 | #[cfg(any(feature = "derive", feature = "full"))] | |
787 | pub fn fold_angle_bracketed_generic_arguments<F>( | |
788 | f: &mut F, | |
789 | node: AngleBracketedGenericArguments, | |
790 | ) -> AngleBracketedGenericArguments | |
791 | where | |
792 | F: Fold + ?Sized, | |
793 | { | |
794 | AngleBracketedGenericArguments { | |
1b1a35ee XL |
795 | colon2_token: (node.colon2_token).map(|it| Token ! [::](tokens_helper(f, &it.spans))), |
796 | lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)), | |
e74abb32 | 797 | args: FoldHelper::lift(node.args, |it| f.fold_generic_argument(it)), |
1b1a35ee | 798 | gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)), |
e74abb32 XL |
799 | } |
800 | } | |
801 | #[cfg(feature = "full")] | |
802 | pub fn fold_arm<F>(f: &mut F, node: Arm) -> Arm | |
803 | where | |
804 | F: Fold + ?Sized, | |
805 | { | |
806 | Arm { | |
807 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
808 | pat: f.fold_pat(node.pat), | |
809 | guard: (node.guard).map(|it| { | |
810 | ( | |
811 | Token![if](tokens_helper(f, &(it).0.span)), | |
812 | Box::new(f.fold_expr(*(it).1)), | |
813 | ) | |
814 | }), | |
1b1a35ee | 815 | fat_arrow_token: Token ! [=>](tokens_helper(f, &node.fat_arrow_token.spans)), |
e74abb32 | 816 | body: Box::new(f.fold_expr(*node.body)), |
1b1a35ee | 817 | comma: (node.comma).map(|it| Token ! [,](tokens_helper(f, &it.spans))), |
e74abb32 XL |
818 | } |
819 | } | |
820 | #[cfg(any(feature = "derive", feature = "full"))] | |
821 | pub fn fold_attr_style<F>(f: &mut F, node: AttrStyle) -> AttrStyle | |
822 | where | |
823 | F: Fold + ?Sized, | |
824 | { | |
825 | match node { | |
826 | AttrStyle::Outer => AttrStyle::Outer, | |
827 | AttrStyle::Inner(_binding_0) => { | |
828 | AttrStyle::Inner(Token![!](tokens_helper(f, &_binding_0.spans))) | |
829 | } | |
830 | } | |
831 | } | |
832 | #[cfg(any(feature = "derive", feature = "full"))] | |
833 | pub fn fold_attribute<F>(f: &mut F, node: Attribute) -> Attribute | |
834 | where | |
835 | F: Fold + ?Sized, | |
836 | { | |
837 | Attribute { | |
1b1a35ee | 838 | pound_token: Token ! [#](tokens_helper(f, &node.pound_token.spans)), |
e74abb32 XL |
839 | style: f.fold_attr_style(node.style), |
840 | bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), | |
841 | path: f.fold_path(node.path), | |
842 | tokens: node.tokens, | |
843 | } | |
844 | } | |
845 | #[cfg(any(feature = "derive", feature = "full"))] | |
846 | pub fn fold_bare_fn_arg<F>(f: &mut F, node: BareFnArg) -> BareFnArg | |
847 | where | |
848 | F: Fold + ?Sized, | |
849 | { | |
850 | BareFnArg { | |
851 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
852 | name: (node.name).map(|it| { | |
853 | ( | |
854 | f.fold_ident((it).0), | |
1b1a35ee | 855 | Token ! [:](tokens_helper(f, &(it).1.spans)), |
e74abb32 XL |
856 | ) |
857 | }), | |
858 | ty: f.fold_type(node.ty), | |
859 | } | |
860 | } | |
861 | #[cfg(any(feature = "derive", feature = "full"))] | |
862 | pub fn fold_bin_op<F>(f: &mut F, node: BinOp) -> BinOp | |
863 | where | |
864 | F: Fold + ?Sized, | |
865 | { | |
866 | match node { | |
1b1a35ee XL |
867 | BinOp::Add(_binding_0) => BinOp::Add(Token ! [+](tokens_helper(f, &_binding_0.spans))), |
868 | BinOp::Sub(_binding_0) => BinOp::Sub(Token ! [-](tokens_helper(f, &_binding_0.spans))), | |
869 | BinOp::Mul(_binding_0) => BinOp::Mul(Token ! [*](tokens_helper(f, &_binding_0.spans))), | |
870 | BinOp::Div(_binding_0) => BinOp::Div(Token ! [/](tokens_helper(f, &_binding_0.spans))), | |
871 | BinOp::Rem(_binding_0) => BinOp::Rem(Token ! [%](tokens_helper(f, &_binding_0.spans))), | |
872 | BinOp::And(_binding_0) => BinOp::And(Token ! [&&](tokens_helper(f, &_binding_0.spans))), | |
873 | BinOp::Or(_binding_0) => BinOp::Or(Token ! [||](tokens_helper(f, &_binding_0.spans))), | |
e74abb32 | 874 | BinOp::BitXor(_binding_0) => { |
1b1a35ee | 875 | BinOp::BitXor(Token ! [^](tokens_helper(f, &_binding_0.spans))) |
e74abb32 XL |
876 | } |
877 | BinOp::BitAnd(_binding_0) => { | |
1b1a35ee | 878 | BinOp::BitAnd(Token ! [&](tokens_helper(f, &_binding_0.spans))) |
e74abb32 | 879 | } |
1b1a35ee XL |
880 | BinOp::BitOr(_binding_0) => BinOp::BitOr(Token ! [|](tokens_helper(f, &_binding_0.spans))), |
881 | BinOp::Shl(_binding_0) => BinOp::Shl(Token ! [<<](tokens_helper(f, &_binding_0.spans))), | |
882 | BinOp::Shr(_binding_0) => BinOp::Shr(Token ! [>>](tokens_helper(f, &_binding_0.spans))), | |
883 | BinOp::Eq(_binding_0) => BinOp::Eq(Token ! [==](tokens_helper(f, &_binding_0.spans))), | |
884 | BinOp::Lt(_binding_0) => BinOp::Lt(Token ! [<](tokens_helper(f, &_binding_0.spans))), | |
885 | BinOp::Le(_binding_0) => BinOp::Le(Token ! [<=](tokens_helper(f, &_binding_0.spans))), | |
886 | BinOp::Ne(_binding_0) => BinOp::Ne(Token ! [!=](tokens_helper(f, &_binding_0.spans))), | |
887 | BinOp::Ge(_binding_0) => BinOp::Ge(Token ! [>=](tokens_helper(f, &_binding_0.spans))), | |
888 | BinOp::Gt(_binding_0) => BinOp::Gt(Token ! [>](tokens_helper(f, &_binding_0.spans))), | |
889 | BinOp::AddEq(_binding_0) => BinOp::AddEq(Token ! [+=](tokens_helper(f, &_binding_0.spans))), | |
890 | BinOp::SubEq(_binding_0) => BinOp::SubEq(Token ! [-=](tokens_helper(f, &_binding_0.spans))), | |
891 | BinOp::MulEq(_binding_0) => BinOp::MulEq(Token ! [*=](tokens_helper(f, &_binding_0.spans))), | |
892 | BinOp::DivEq(_binding_0) => BinOp::DivEq(Token ! [/=](tokens_helper(f, &_binding_0.spans))), | |
893 | BinOp::RemEq(_binding_0) => BinOp::RemEq(Token ! [%=](tokens_helper(f, &_binding_0.spans))), | |
e74abb32 | 894 | BinOp::BitXorEq(_binding_0) => { |
1b1a35ee | 895 | BinOp::BitXorEq(Token ! [^=](tokens_helper(f, &_binding_0.spans))) |
e74abb32 XL |
896 | } |
897 | BinOp::BitAndEq(_binding_0) => { | |
1b1a35ee | 898 | BinOp::BitAndEq(Token ! [&=](tokens_helper(f, &_binding_0.spans))) |
e74abb32 XL |
899 | } |
900 | BinOp::BitOrEq(_binding_0) => { | |
1b1a35ee | 901 | BinOp::BitOrEq(Token ! [|=](tokens_helper(f, &_binding_0.spans))) |
e74abb32 XL |
902 | } |
903 | BinOp::ShlEq(_binding_0) => { | |
1b1a35ee | 904 | BinOp::ShlEq(Token ! [<<=](tokens_helper(f, &_binding_0.spans))) |
e74abb32 XL |
905 | } |
906 | BinOp::ShrEq(_binding_0) => { | |
1b1a35ee | 907 | BinOp::ShrEq(Token ! [>>=](tokens_helper(f, &_binding_0.spans))) |
e74abb32 XL |
908 | } |
909 | } | |
910 | } | |
911 | #[cfg(any(feature = "derive", feature = "full"))] | |
912 | pub fn fold_binding<F>(f: &mut F, node: Binding) -> Binding | |
913 | where | |
914 | F: Fold + ?Sized, | |
915 | { | |
916 | Binding { | |
917 | ident: f.fold_ident(node.ident), | |
1b1a35ee | 918 | eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), |
e74abb32 XL |
919 | ty: f.fold_type(node.ty), |
920 | } | |
921 | } | |
922 | #[cfg(feature = "full")] | |
923 | pub fn fold_block<F>(f: &mut F, node: Block) -> Block | |
924 | where | |
925 | F: Fold + ?Sized, | |
926 | { | |
927 | Block { | |
928 | brace_token: Brace(tokens_helper(f, &node.brace_token.span)), | |
929 | stmts: FoldHelper::lift(node.stmts, |it| f.fold_stmt(it)), | |
930 | } | |
931 | } | |
932 | #[cfg(any(feature = "derive", feature = "full"))] | |
933 | pub fn fold_bound_lifetimes<F>(f: &mut F, node: BoundLifetimes) -> BoundLifetimes | |
934 | where | |
935 | F: Fold + ?Sized, | |
936 | { | |
937 | BoundLifetimes { | |
938 | for_token: Token![for](tokens_helper(f, &node.for_token.span)), | |
1b1a35ee | 939 | lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)), |
e74abb32 | 940 | lifetimes: FoldHelper::lift(node.lifetimes, |it| f.fold_lifetime_def(it)), |
1b1a35ee | 941 | gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)), |
e74abb32 XL |
942 | } |
943 | } | |
944 | #[cfg(any(feature = "derive", feature = "full"))] | |
945 | pub fn fold_const_param<F>(f: &mut F, node: ConstParam) -> ConstParam | |
946 | where | |
947 | F: Fold + ?Sized, | |
948 | { | |
949 | ConstParam { | |
950 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
951 | const_token: Token![const](tokens_helper(f, &node.const_token.span)), | |
952 | ident: f.fold_ident(node.ident), | |
1b1a35ee | 953 | colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), |
e74abb32 | 954 | ty: f.fold_type(node.ty), |
1b1a35ee | 955 | eq_token: (node.eq_token).map(|it| Token ! [=](tokens_helper(f, &it.spans))), |
e74abb32 XL |
956 | default: (node.default).map(|it| f.fold_expr(it)), |
957 | } | |
958 | } | |
959 | #[cfg(any(feature = "derive", feature = "full"))] | |
960 | pub fn fold_constraint<F>(f: &mut F, node: Constraint) -> Constraint | |
961 | where | |
962 | F: Fold + ?Sized, | |
963 | { | |
964 | Constraint { | |
965 | ident: f.fold_ident(node.ident), | |
1b1a35ee | 966 | colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), |
e74abb32 XL |
967 | bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), |
968 | } | |
969 | } | |
970 | #[cfg(feature = "derive")] | |
971 | pub fn fold_data<F>(f: &mut F, node: Data) -> Data | |
972 | where | |
973 | F: Fold + ?Sized, | |
974 | { | |
975 | match node { | |
976 | Data::Struct(_binding_0) => Data::Struct(f.fold_data_struct(_binding_0)), | |
977 | Data::Enum(_binding_0) => Data::Enum(f.fold_data_enum(_binding_0)), | |
978 | Data::Union(_binding_0) => Data::Union(f.fold_data_union(_binding_0)), | |
979 | } | |
980 | } | |
981 | #[cfg(feature = "derive")] | |
982 | pub fn fold_data_enum<F>(f: &mut F, node: DataEnum) -> DataEnum | |
983 | where | |
984 | F: Fold + ?Sized, | |
985 | { | |
986 | DataEnum { | |
987 | enum_token: Token![enum](tokens_helper(f, &node.enum_token.span)), | |
988 | brace_token: Brace(tokens_helper(f, &node.brace_token.span)), | |
989 | variants: FoldHelper::lift(node.variants, |it| f.fold_variant(it)), | |
990 | } | |
991 | } | |
992 | #[cfg(feature = "derive")] | |
993 | pub fn fold_data_struct<F>(f: &mut F, node: DataStruct) -> DataStruct | |
994 | where | |
995 | F: Fold + ?Sized, | |
996 | { | |
997 | DataStruct { | |
998 | struct_token: Token![struct](tokens_helper(f, &node.struct_token.span)), | |
999 | fields: f.fold_fields(node.fields), | |
1b1a35ee | 1000 | semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), |
e74abb32 XL |
1001 | } |
1002 | } | |
1003 | #[cfg(feature = "derive")] | |
1004 | pub fn fold_data_union<F>(f: &mut F, node: DataUnion) -> DataUnion | |
1005 | where | |
1006 | F: Fold + ?Sized, | |
1007 | { | |
1008 | DataUnion { | |
1009 | union_token: Token![union](tokens_helper(f, &node.union_token.span)), | |
1010 | fields: f.fold_fields_named(node.fields), | |
1011 | } | |
1012 | } | |
1013 | #[cfg(feature = "derive")] | |
1014 | pub fn fold_derive_input<F>(f: &mut F, node: DeriveInput) -> DeriveInput | |
1015 | where | |
1016 | F: Fold + ?Sized, | |
1017 | { | |
1018 | DeriveInput { | |
1019 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1020 | vis: f.fold_visibility(node.vis), | |
1021 | ident: f.fold_ident(node.ident), | |
1022 | generics: f.fold_generics(node.generics), | |
1023 | data: f.fold_data(node.data), | |
1024 | } | |
1025 | } | |
1026 | #[cfg(any(feature = "derive", feature = "full"))] | |
1027 | pub fn fold_expr<F>(f: &mut F, node: Expr) -> Expr | |
1028 | where | |
1029 | F: Fold + ?Sized, | |
1030 | { | |
1031 | match node { | |
1032 | Expr::Array(_binding_0) => Expr::Array(full!(f.fold_expr_array(_binding_0))), | |
1033 | Expr::Assign(_binding_0) => Expr::Assign(full!(f.fold_expr_assign(_binding_0))), | |
1034 | Expr::AssignOp(_binding_0) => Expr::AssignOp(full!(f.fold_expr_assign_op(_binding_0))), | |
1035 | Expr::Async(_binding_0) => Expr::Async(full!(f.fold_expr_async(_binding_0))), | |
1036 | Expr::Await(_binding_0) => Expr::Await(full!(f.fold_expr_await(_binding_0))), | |
1037 | Expr::Binary(_binding_0) => Expr::Binary(f.fold_expr_binary(_binding_0)), | |
1038 | Expr::Block(_binding_0) => Expr::Block(full!(f.fold_expr_block(_binding_0))), | |
1039 | Expr::Box(_binding_0) => Expr::Box(full!(f.fold_expr_box(_binding_0))), | |
1040 | Expr::Break(_binding_0) => Expr::Break(full!(f.fold_expr_break(_binding_0))), | |
1041 | Expr::Call(_binding_0) => Expr::Call(f.fold_expr_call(_binding_0)), | |
1042 | Expr::Cast(_binding_0) => Expr::Cast(f.fold_expr_cast(_binding_0)), | |
1043 | Expr::Closure(_binding_0) => Expr::Closure(full!(f.fold_expr_closure(_binding_0))), | |
1044 | Expr::Continue(_binding_0) => Expr::Continue(full!(f.fold_expr_continue(_binding_0))), | |
1045 | Expr::Field(_binding_0) => Expr::Field(f.fold_expr_field(_binding_0)), | |
1046 | Expr::ForLoop(_binding_0) => Expr::ForLoop(full!(f.fold_expr_for_loop(_binding_0))), | |
1047 | Expr::Group(_binding_0) => Expr::Group(full!(f.fold_expr_group(_binding_0))), | |
1048 | Expr::If(_binding_0) => Expr::If(full!(f.fold_expr_if(_binding_0))), | |
1049 | Expr::Index(_binding_0) => Expr::Index(f.fold_expr_index(_binding_0)), | |
1050 | Expr::Let(_binding_0) => Expr::Let(full!(f.fold_expr_let(_binding_0))), | |
1051 | Expr::Lit(_binding_0) => Expr::Lit(f.fold_expr_lit(_binding_0)), | |
1052 | Expr::Loop(_binding_0) => Expr::Loop(full!(f.fold_expr_loop(_binding_0))), | |
1053 | Expr::Macro(_binding_0) => Expr::Macro(full!(f.fold_expr_macro(_binding_0))), | |
1054 | Expr::Match(_binding_0) => Expr::Match(full!(f.fold_expr_match(_binding_0))), | |
1055 | Expr::MethodCall(_binding_0) => { | |
1056 | Expr::MethodCall(full!(f.fold_expr_method_call(_binding_0))) | |
1057 | } | |
1058 | Expr::Paren(_binding_0) => Expr::Paren(f.fold_expr_paren(_binding_0)), | |
1059 | Expr::Path(_binding_0) => Expr::Path(f.fold_expr_path(_binding_0)), | |
1060 | Expr::Range(_binding_0) => Expr::Range(full!(f.fold_expr_range(_binding_0))), | |
1061 | Expr::Reference(_binding_0) => Expr::Reference(full!(f.fold_expr_reference(_binding_0))), | |
1062 | Expr::Repeat(_binding_0) => Expr::Repeat(full!(f.fold_expr_repeat(_binding_0))), | |
1063 | Expr::Return(_binding_0) => Expr::Return(full!(f.fold_expr_return(_binding_0))), | |
1064 | Expr::Struct(_binding_0) => Expr::Struct(full!(f.fold_expr_struct(_binding_0))), | |
1065 | Expr::Try(_binding_0) => Expr::Try(full!(f.fold_expr_try(_binding_0))), | |
1066 | Expr::TryBlock(_binding_0) => Expr::TryBlock(full!(f.fold_expr_try_block(_binding_0))), | |
1067 | Expr::Tuple(_binding_0) => Expr::Tuple(full!(f.fold_expr_tuple(_binding_0))), | |
1068 | Expr::Type(_binding_0) => Expr::Type(full!(f.fold_expr_type(_binding_0))), | |
1069 | Expr::Unary(_binding_0) => Expr::Unary(f.fold_expr_unary(_binding_0)), | |
1070 | Expr::Unsafe(_binding_0) => Expr::Unsafe(full!(f.fold_expr_unsafe(_binding_0))), | |
1071 | Expr::Verbatim(_binding_0) => Expr::Verbatim(_binding_0), | |
1072 | Expr::While(_binding_0) => Expr::While(full!(f.fold_expr_while(_binding_0))), | |
1073 | Expr::Yield(_binding_0) => Expr::Yield(full!(f.fold_expr_yield(_binding_0))), | |
1074 | _ => unreachable!(), | |
1075 | } | |
1076 | } | |
1077 | #[cfg(feature = "full")] | |
1078 | pub fn fold_expr_array<F>(f: &mut F, node: ExprArray) -> ExprArray | |
1079 | where | |
1080 | F: Fold + ?Sized, | |
1081 | { | |
1082 | ExprArray { | |
1083 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1084 | bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), | |
1085 | elems: FoldHelper::lift(node.elems, |it| f.fold_expr(it)), | |
1086 | } | |
1087 | } | |
1088 | #[cfg(feature = "full")] | |
1089 | pub fn fold_expr_assign<F>(f: &mut F, node: ExprAssign) -> ExprAssign | |
1090 | where | |
1091 | F: Fold + ?Sized, | |
1092 | { | |
1093 | ExprAssign { | |
1094 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1095 | left: Box::new(f.fold_expr(*node.left)), | |
1b1a35ee | 1096 | eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), |
e74abb32 XL |
1097 | right: Box::new(f.fold_expr(*node.right)), |
1098 | } | |
1099 | } | |
1100 | #[cfg(feature = "full")] | |
1101 | pub fn fold_expr_assign_op<F>(f: &mut F, node: ExprAssignOp) -> ExprAssignOp | |
1102 | where | |
1103 | F: Fold + ?Sized, | |
1104 | { | |
1105 | ExprAssignOp { | |
1106 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1107 | left: Box::new(f.fold_expr(*node.left)), | |
1108 | op: f.fold_bin_op(node.op), | |
1109 | right: Box::new(f.fold_expr(*node.right)), | |
1110 | } | |
1111 | } | |
1112 | #[cfg(feature = "full")] | |
1113 | pub fn fold_expr_async<F>(f: &mut F, node: ExprAsync) -> ExprAsync | |
1114 | where | |
1115 | F: Fold + ?Sized, | |
1116 | { | |
1117 | ExprAsync { | |
1118 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1119 | async_token: Token![async](tokens_helper(f, &node.async_token.span)), | |
1120 | capture: (node.capture).map(|it| Token![move](tokens_helper(f, &it.span))), | |
1121 | block: f.fold_block(node.block), | |
1122 | } | |
1123 | } | |
1124 | #[cfg(feature = "full")] | |
1125 | pub fn fold_expr_await<F>(f: &mut F, node: ExprAwait) -> ExprAwait | |
1126 | where | |
1127 | F: Fold + ?Sized, | |
1128 | { | |
1129 | ExprAwait { | |
1130 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1131 | base: Box::new(f.fold_expr(*node.base)), | |
1b1a35ee | 1132 | dot_token: Token ! [.](tokens_helper(f, &node.dot_token.spans)), |
e74abb32 XL |
1133 | await_token: crate::token::Await(tokens_helper(f, &node.await_token.span)), |
1134 | } | |
1135 | } | |
1136 | #[cfg(any(feature = "derive", feature = "full"))] | |
1137 | pub fn fold_expr_binary<F>(f: &mut F, node: ExprBinary) -> ExprBinary | |
1138 | where | |
1139 | F: Fold + ?Sized, | |
1140 | { | |
1141 | ExprBinary { | |
1142 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1143 | left: Box::new(f.fold_expr(*node.left)), | |
1144 | op: f.fold_bin_op(node.op), | |
1145 | right: Box::new(f.fold_expr(*node.right)), | |
1146 | } | |
1147 | } | |
1148 | #[cfg(feature = "full")] | |
1149 | pub fn fold_expr_block<F>(f: &mut F, node: ExprBlock) -> ExprBlock | |
1150 | where | |
1151 | F: Fold + ?Sized, | |
1152 | { | |
1153 | ExprBlock { | |
1154 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1155 | label: (node.label).map(|it| f.fold_label(it)), | |
1156 | block: f.fold_block(node.block), | |
1157 | } | |
1158 | } | |
1159 | #[cfg(feature = "full")] | |
1160 | pub fn fold_expr_box<F>(f: &mut F, node: ExprBox) -> ExprBox | |
1161 | where | |
1162 | F: Fold + ?Sized, | |
1163 | { | |
1164 | ExprBox { | |
1165 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1166 | box_token: Token![box](tokens_helper(f, &node.box_token.span)), | |
1167 | expr: Box::new(f.fold_expr(*node.expr)), | |
1168 | } | |
1169 | } | |
1170 | #[cfg(feature = "full")] | |
1171 | pub fn fold_expr_break<F>(f: &mut F, node: ExprBreak) -> ExprBreak | |
1172 | where | |
1173 | F: Fold + ?Sized, | |
1174 | { | |
1175 | ExprBreak { | |
1176 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1177 | break_token: Token![break](tokens_helper(f, &node.break_token.span)), | |
1178 | label: (node.label).map(|it| f.fold_lifetime(it)), | |
1179 | expr: (node.expr).map(|it| Box::new(f.fold_expr(*it))), | |
1180 | } | |
1181 | } | |
1182 | #[cfg(any(feature = "derive", feature = "full"))] | |
1183 | pub fn fold_expr_call<F>(f: &mut F, node: ExprCall) -> ExprCall | |
1184 | where | |
1185 | F: Fold + ?Sized, | |
1186 | { | |
1187 | ExprCall { | |
1188 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1189 | func: Box::new(f.fold_expr(*node.func)), | |
1190 | paren_token: Paren(tokens_helper(f, &node.paren_token.span)), | |
1191 | args: FoldHelper::lift(node.args, |it| f.fold_expr(it)), | |
1192 | } | |
1193 | } | |
1194 | #[cfg(any(feature = "derive", feature = "full"))] | |
1195 | pub fn fold_expr_cast<F>(f: &mut F, node: ExprCast) -> ExprCast | |
1196 | where | |
1197 | F: Fold + ?Sized, | |
1198 | { | |
1199 | ExprCast { | |
1200 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1201 | expr: Box::new(f.fold_expr(*node.expr)), | |
1202 | as_token: Token![as](tokens_helper(f, &node.as_token.span)), | |
1203 | ty: Box::new(f.fold_type(*node.ty)), | |
1204 | } | |
1205 | } | |
1206 | #[cfg(feature = "full")] | |
1207 | pub fn fold_expr_closure<F>(f: &mut F, node: ExprClosure) -> ExprClosure | |
1208 | where | |
1209 | F: Fold + ?Sized, | |
1210 | { | |
1211 | ExprClosure { | |
1212 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1213 | asyncness: (node.asyncness).map(|it| Token![async](tokens_helper(f, &it.span))), | |
1214 | movability: (node.movability).map(|it| Token![static](tokens_helper(f, &it.span))), | |
1215 | capture: (node.capture).map(|it| Token![move](tokens_helper(f, &it.span))), | |
1b1a35ee | 1216 | or1_token: Token ! [|](tokens_helper(f, &node.or1_token.spans)), |
e74abb32 | 1217 | inputs: FoldHelper::lift(node.inputs, |it| f.fold_pat(it)), |
1b1a35ee | 1218 | or2_token: Token ! [|](tokens_helper(f, &node.or2_token.spans)), |
e74abb32 XL |
1219 | output: f.fold_return_type(node.output), |
1220 | body: Box::new(f.fold_expr(*node.body)), | |
1221 | } | |
1222 | } | |
1223 | #[cfg(feature = "full")] | |
1224 | pub fn fold_expr_continue<F>(f: &mut F, node: ExprContinue) -> ExprContinue | |
1225 | where | |
1226 | F: Fold + ?Sized, | |
1227 | { | |
1228 | ExprContinue { | |
1229 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1230 | continue_token: Token![continue](tokens_helper(f, &node.continue_token.span)), | |
1231 | label: (node.label).map(|it| f.fold_lifetime(it)), | |
1232 | } | |
1233 | } | |
1234 | #[cfg(any(feature = "derive", feature = "full"))] | |
1235 | pub fn fold_expr_field<F>(f: &mut F, node: ExprField) -> ExprField | |
1236 | where | |
1237 | F: Fold + ?Sized, | |
1238 | { | |
1239 | ExprField { | |
1240 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1241 | base: Box::new(f.fold_expr(*node.base)), | |
1b1a35ee | 1242 | dot_token: Token ! [.](tokens_helper(f, &node.dot_token.spans)), |
e74abb32 XL |
1243 | member: f.fold_member(node.member), |
1244 | } | |
1245 | } | |
1246 | #[cfg(feature = "full")] | |
1247 | pub fn fold_expr_for_loop<F>(f: &mut F, node: ExprForLoop) -> ExprForLoop | |
1248 | where | |
1249 | F: Fold + ?Sized, | |
1250 | { | |
1251 | ExprForLoop { | |
1252 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1253 | label: (node.label).map(|it| f.fold_label(it)), | |
1254 | for_token: Token![for](tokens_helper(f, &node.for_token.span)), | |
1255 | pat: f.fold_pat(node.pat), | |
1256 | in_token: Token![in](tokens_helper(f, &node.in_token.span)), | |
1257 | expr: Box::new(f.fold_expr(*node.expr)), | |
1258 | body: f.fold_block(node.body), | |
1259 | } | |
1260 | } | |
1261 | #[cfg(feature = "full")] | |
1262 | pub fn fold_expr_group<F>(f: &mut F, node: ExprGroup) -> ExprGroup | |
1263 | where | |
1264 | F: Fold + ?Sized, | |
1265 | { | |
1266 | ExprGroup { | |
1267 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1268 | group_token: Group(tokens_helper(f, &node.group_token.span)), | |
1269 | expr: Box::new(f.fold_expr(*node.expr)), | |
1270 | } | |
1271 | } | |
1272 | #[cfg(feature = "full")] | |
1273 | pub fn fold_expr_if<F>(f: &mut F, node: ExprIf) -> ExprIf | |
1274 | where | |
1275 | F: Fold + ?Sized, | |
1276 | { | |
1277 | ExprIf { | |
1278 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1279 | if_token: Token![if](tokens_helper(f, &node.if_token.span)), | |
1280 | cond: Box::new(f.fold_expr(*node.cond)), | |
1281 | then_branch: f.fold_block(node.then_branch), | |
1282 | else_branch: (node.else_branch).map(|it| { | |
1283 | ( | |
1284 | Token![else](tokens_helper(f, &(it).0.span)), | |
1285 | Box::new(f.fold_expr(*(it).1)), | |
1286 | ) | |
1287 | }), | |
1288 | } | |
1289 | } | |
1290 | #[cfg(any(feature = "derive", feature = "full"))] | |
1291 | pub fn fold_expr_index<F>(f: &mut F, node: ExprIndex) -> ExprIndex | |
1292 | where | |
1293 | F: Fold + ?Sized, | |
1294 | { | |
1295 | ExprIndex { | |
1296 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1297 | expr: Box::new(f.fold_expr(*node.expr)), | |
1298 | bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), | |
1299 | index: Box::new(f.fold_expr(*node.index)), | |
1300 | } | |
1301 | } | |
1302 | #[cfg(feature = "full")] | |
1303 | pub fn fold_expr_let<F>(f: &mut F, node: ExprLet) -> ExprLet | |
1304 | where | |
1305 | F: Fold + ?Sized, | |
1306 | { | |
1307 | ExprLet { | |
1308 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1309 | let_token: Token![let](tokens_helper(f, &node.let_token.span)), | |
1310 | pat: f.fold_pat(node.pat), | |
1b1a35ee | 1311 | eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), |
e74abb32 XL |
1312 | expr: Box::new(f.fold_expr(*node.expr)), |
1313 | } | |
1314 | } | |
1315 | #[cfg(any(feature = "derive", feature = "full"))] | |
1316 | pub fn fold_expr_lit<F>(f: &mut F, node: ExprLit) -> ExprLit | |
1317 | where | |
1318 | F: Fold + ?Sized, | |
1319 | { | |
1320 | ExprLit { | |
1321 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1322 | lit: f.fold_lit(node.lit), | |
1323 | } | |
1324 | } | |
1325 | #[cfg(feature = "full")] | |
1326 | pub fn fold_expr_loop<F>(f: &mut F, node: ExprLoop) -> ExprLoop | |
1327 | where | |
1328 | F: Fold + ?Sized, | |
1329 | { | |
1330 | ExprLoop { | |
1331 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1332 | label: (node.label).map(|it| f.fold_label(it)), | |
1333 | loop_token: Token![loop](tokens_helper(f, &node.loop_token.span)), | |
1334 | body: f.fold_block(node.body), | |
1335 | } | |
1336 | } | |
1337 | #[cfg(feature = "full")] | |
1338 | pub fn fold_expr_macro<F>(f: &mut F, node: ExprMacro) -> ExprMacro | |
1339 | where | |
1340 | F: Fold + ?Sized, | |
1341 | { | |
1342 | ExprMacro { | |
1343 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1344 | mac: f.fold_macro(node.mac), | |
1345 | } | |
1346 | } | |
1347 | #[cfg(feature = "full")] | |
1348 | pub fn fold_expr_match<F>(f: &mut F, node: ExprMatch) -> ExprMatch | |
1349 | where | |
1350 | F: Fold + ?Sized, | |
1351 | { | |
1352 | ExprMatch { | |
1353 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1354 | match_token: Token![match](tokens_helper(f, &node.match_token.span)), | |
1355 | expr: Box::new(f.fold_expr(*node.expr)), | |
1356 | brace_token: Brace(tokens_helper(f, &node.brace_token.span)), | |
1357 | arms: FoldHelper::lift(node.arms, |it| f.fold_arm(it)), | |
1358 | } | |
1359 | } | |
1360 | #[cfg(feature = "full")] | |
1361 | pub fn fold_expr_method_call<F>(f: &mut F, node: ExprMethodCall) -> ExprMethodCall | |
1362 | where | |
1363 | F: Fold + ?Sized, | |
1364 | { | |
1365 | ExprMethodCall { | |
1366 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1367 | receiver: Box::new(f.fold_expr(*node.receiver)), | |
1b1a35ee | 1368 | dot_token: Token ! [.](tokens_helper(f, &node.dot_token.spans)), |
e74abb32 XL |
1369 | method: f.fold_ident(node.method), |
1370 | turbofish: (node.turbofish).map(|it| f.fold_method_turbofish(it)), | |
1371 | paren_token: Paren(tokens_helper(f, &node.paren_token.span)), | |
1372 | args: FoldHelper::lift(node.args, |it| f.fold_expr(it)), | |
1373 | } | |
1374 | } | |
1375 | #[cfg(any(feature = "derive", feature = "full"))] | |
1376 | pub fn fold_expr_paren<F>(f: &mut F, node: ExprParen) -> ExprParen | |
1377 | where | |
1378 | F: Fold + ?Sized, | |
1379 | { | |
1380 | ExprParen { | |
1381 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1382 | paren_token: Paren(tokens_helper(f, &node.paren_token.span)), | |
1383 | expr: Box::new(f.fold_expr(*node.expr)), | |
1384 | } | |
1385 | } | |
1386 | #[cfg(any(feature = "derive", feature = "full"))] | |
1387 | pub fn fold_expr_path<F>(f: &mut F, node: ExprPath) -> ExprPath | |
1388 | where | |
1389 | F: Fold + ?Sized, | |
1390 | { | |
1391 | ExprPath { | |
1392 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1393 | qself: (node.qself).map(|it| f.fold_qself(it)), | |
1394 | path: f.fold_path(node.path), | |
1395 | } | |
1396 | } | |
1397 | #[cfg(feature = "full")] | |
1398 | pub fn fold_expr_range<F>(f: &mut F, node: ExprRange) -> ExprRange | |
1399 | where | |
1400 | F: Fold + ?Sized, | |
1401 | { | |
1402 | ExprRange { | |
1403 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1404 | from: (node.from).map(|it| Box::new(f.fold_expr(*it))), | |
1405 | limits: f.fold_range_limits(node.limits), | |
1406 | to: (node.to).map(|it| Box::new(f.fold_expr(*it))), | |
1407 | } | |
1408 | } | |
1409 | #[cfg(feature = "full")] | |
1410 | pub fn fold_expr_reference<F>(f: &mut F, node: ExprReference) -> ExprReference | |
1411 | where | |
1412 | F: Fold + ?Sized, | |
1413 | { | |
1414 | ExprReference { | |
1415 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1b1a35ee | 1416 | and_token: Token ! [&](tokens_helper(f, &node.and_token.spans)), |
e74abb32 XL |
1417 | raw: node.raw, |
1418 | mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), | |
1419 | expr: Box::new(f.fold_expr(*node.expr)), | |
1420 | } | |
1421 | } | |
1422 | #[cfg(feature = "full")] | |
1423 | pub fn fold_expr_repeat<F>(f: &mut F, node: ExprRepeat) -> ExprRepeat | |
1424 | where | |
1425 | F: Fold + ?Sized, | |
1426 | { | |
1427 | ExprRepeat { | |
1428 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1429 | bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), | |
1430 | expr: Box::new(f.fold_expr(*node.expr)), | |
1b1a35ee | 1431 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
1432 | len: Box::new(f.fold_expr(*node.len)), |
1433 | } | |
1434 | } | |
1435 | #[cfg(feature = "full")] | |
1436 | pub fn fold_expr_return<F>(f: &mut F, node: ExprReturn) -> ExprReturn | |
1437 | where | |
1438 | F: Fold + ?Sized, | |
1439 | { | |
1440 | ExprReturn { | |
1441 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1442 | return_token: Token![return](tokens_helper(f, &node.return_token.span)), | |
1443 | expr: (node.expr).map(|it| Box::new(f.fold_expr(*it))), | |
1444 | } | |
1445 | } | |
1446 | #[cfg(feature = "full")] | |
1447 | pub fn fold_expr_struct<F>(f: &mut F, node: ExprStruct) -> ExprStruct | |
1448 | where | |
1449 | F: Fold + ?Sized, | |
1450 | { | |
1451 | ExprStruct { | |
1452 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1453 | path: f.fold_path(node.path), | |
1454 | brace_token: Brace(tokens_helper(f, &node.brace_token.span)), | |
1455 | fields: FoldHelper::lift(node.fields, |it| f.fold_field_value(it)), | |
1456 | dot2_token: (node.dot2_token).map(|it| Token![..](tokens_helper(f, &it.spans))), | |
1457 | rest: (node.rest).map(|it| Box::new(f.fold_expr(*it))), | |
1458 | } | |
1459 | } | |
1460 | #[cfg(feature = "full")] | |
1461 | pub fn fold_expr_try<F>(f: &mut F, node: ExprTry) -> ExprTry | |
1462 | where | |
1463 | F: Fold + ?Sized, | |
1464 | { | |
1465 | ExprTry { | |
1466 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1467 | expr: Box::new(f.fold_expr(*node.expr)), | |
1b1a35ee | 1468 | question_token: Token ! [?](tokens_helper(f, &node.question_token.spans)), |
e74abb32 XL |
1469 | } |
1470 | } | |
1471 | #[cfg(feature = "full")] | |
1472 | pub fn fold_expr_try_block<F>(f: &mut F, node: ExprTryBlock) -> ExprTryBlock | |
1473 | where | |
1474 | F: Fold + ?Sized, | |
1475 | { | |
1476 | ExprTryBlock { | |
1477 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1478 | try_token: Token![try](tokens_helper(f, &node.try_token.span)), | |
1479 | block: f.fold_block(node.block), | |
1480 | } | |
1481 | } | |
1482 | #[cfg(feature = "full")] | |
1483 | pub fn fold_expr_tuple<F>(f: &mut F, node: ExprTuple) -> ExprTuple | |
1484 | where | |
1485 | F: Fold + ?Sized, | |
1486 | { | |
1487 | ExprTuple { | |
1488 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1489 | paren_token: Paren(tokens_helper(f, &node.paren_token.span)), | |
1490 | elems: FoldHelper::lift(node.elems, |it| f.fold_expr(it)), | |
1491 | } | |
1492 | } | |
1493 | #[cfg(feature = "full")] | |
1494 | pub fn fold_expr_type<F>(f: &mut F, node: ExprType) -> ExprType | |
1495 | where | |
1496 | F: Fold + ?Sized, | |
1497 | { | |
1498 | ExprType { | |
1499 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1500 | expr: Box::new(f.fold_expr(*node.expr)), | |
1b1a35ee | 1501 | colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), |
e74abb32 XL |
1502 | ty: Box::new(f.fold_type(*node.ty)), |
1503 | } | |
1504 | } | |
1505 | #[cfg(any(feature = "derive", feature = "full"))] | |
1506 | pub fn fold_expr_unary<F>(f: &mut F, node: ExprUnary) -> ExprUnary | |
1507 | where | |
1508 | F: Fold + ?Sized, | |
1509 | { | |
1510 | ExprUnary { | |
1511 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1512 | op: f.fold_un_op(node.op), | |
1513 | expr: Box::new(f.fold_expr(*node.expr)), | |
1514 | } | |
1515 | } | |
1516 | #[cfg(feature = "full")] | |
1517 | pub fn fold_expr_unsafe<F>(f: &mut F, node: ExprUnsafe) -> ExprUnsafe | |
1518 | where | |
1519 | F: Fold + ?Sized, | |
1520 | { | |
1521 | ExprUnsafe { | |
1522 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1523 | unsafe_token: Token![unsafe](tokens_helper(f, &node.unsafe_token.span)), | |
1524 | block: f.fold_block(node.block), | |
1525 | } | |
1526 | } | |
1527 | #[cfg(feature = "full")] | |
1528 | pub fn fold_expr_while<F>(f: &mut F, node: ExprWhile) -> ExprWhile | |
1529 | where | |
1530 | F: Fold + ?Sized, | |
1531 | { | |
1532 | ExprWhile { | |
1533 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1534 | label: (node.label).map(|it| f.fold_label(it)), | |
1535 | while_token: Token![while](tokens_helper(f, &node.while_token.span)), | |
1536 | cond: Box::new(f.fold_expr(*node.cond)), | |
1537 | body: f.fold_block(node.body), | |
1538 | } | |
1539 | } | |
1540 | #[cfg(feature = "full")] | |
1541 | pub fn fold_expr_yield<F>(f: &mut F, node: ExprYield) -> ExprYield | |
1542 | where | |
1543 | F: Fold + ?Sized, | |
1544 | { | |
1545 | ExprYield { | |
1546 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1547 | yield_token: Token![yield](tokens_helper(f, &node.yield_token.span)), | |
1548 | expr: (node.expr).map(|it| Box::new(f.fold_expr(*it))), | |
1549 | } | |
1550 | } | |
1551 | #[cfg(any(feature = "derive", feature = "full"))] | |
1552 | pub fn fold_field<F>(f: &mut F, node: Field) -> Field | |
1553 | where | |
1554 | F: Fold + ?Sized, | |
1555 | { | |
1556 | Field { | |
1557 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1558 | vis: f.fold_visibility(node.vis), | |
1559 | ident: (node.ident).map(|it| f.fold_ident(it)), | |
1b1a35ee | 1560 | colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), |
e74abb32 XL |
1561 | ty: f.fold_type(node.ty), |
1562 | } | |
1563 | } | |
1564 | #[cfg(feature = "full")] | |
1565 | pub fn fold_field_pat<F>(f: &mut F, node: FieldPat) -> FieldPat | |
1566 | where | |
1567 | F: Fold + ?Sized, | |
1568 | { | |
1569 | FieldPat { | |
1570 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1571 | member: f.fold_member(node.member), | |
1b1a35ee | 1572 | colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), |
e74abb32 XL |
1573 | pat: Box::new(f.fold_pat(*node.pat)), |
1574 | } | |
1575 | } | |
1576 | #[cfg(feature = "full")] | |
1577 | pub fn fold_field_value<F>(f: &mut F, node: FieldValue) -> FieldValue | |
1578 | where | |
1579 | F: Fold + ?Sized, | |
1580 | { | |
1581 | FieldValue { | |
1582 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1583 | member: f.fold_member(node.member), | |
1b1a35ee | 1584 | colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), |
e74abb32 XL |
1585 | expr: f.fold_expr(node.expr), |
1586 | } | |
1587 | } | |
1588 | #[cfg(any(feature = "derive", feature = "full"))] | |
1589 | pub fn fold_fields<F>(f: &mut F, node: Fields) -> Fields | |
1590 | where | |
1591 | F: Fold + ?Sized, | |
1592 | { | |
1593 | match node { | |
1594 | Fields::Named(_binding_0) => Fields::Named(f.fold_fields_named(_binding_0)), | |
1595 | Fields::Unnamed(_binding_0) => Fields::Unnamed(f.fold_fields_unnamed(_binding_0)), | |
1596 | Fields::Unit => Fields::Unit, | |
1597 | } | |
1598 | } | |
1599 | #[cfg(any(feature = "derive", feature = "full"))] | |
1600 | pub fn fold_fields_named<F>(f: &mut F, node: FieldsNamed) -> FieldsNamed | |
1601 | where | |
1602 | F: Fold + ?Sized, | |
1603 | { | |
1604 | FieldsNamed { | |
1605 | brace_token: Brace(tokens_helper(f, &node.brace_token.span)), | |
1606 | named: FoldHelper::lift(node.named, |it| f.fold_field(it)), | |
1607 | } | |
1608 | } | |
1609 | #[cfg(any(feature = "derive", feature = "full"))] | |
1610 | pub fn fold_fields_unnamed<F>(f: &mut F, node: FieldsUnnamed) -> FieldsUnnamed | |
1611 | where | |
1612 | F: Fold + ?Sized, | |
1613 | { | |
1614 | FieldsUnnamed { | |
1615 | paren_token: Paren(tokens_helper(f, &node.paren_token.span)), | |
1616 | unnamed: FoldHelper::lift(node.unnamed, |it| f.fold_field(it)), | |
1617 | } | |
1618 | } | |
1619 | #[cfg(feature = "full")] | |
1620 | pub fn fold_file<F>(f: &mut F, node: File) -> File | |
1621 | where | |
1622 | F: Fold + ?Sized, | |
1623 | { | |
1624 | File { | |
1625 | shebang: node.shebang, | |
1626 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1627 | items: FoldHelper::lift(node.items, |it| f.fold_item(it)), | |
1628 | } | |
1629 | } | |
1630 | #[cfg(feature = "full")] | |
1631 | pub fn fold_fn_arg<F>(f: &mut F, node: FnArg) -> FnArg | |
1632 | where | |
1633 | F: Fold + ?Sized, | |
1634 | { | |
1635 | match node { | |
1636 | FnArg::Receiver(_binding_0) => FnArg::Receiver(f.fold_receiver(_binding_0)), | |
1637 | FnArg::Typed(_binding_0) => FnArg::Typed(f.fold_pat_type(_binding_0)), | |
1638 | } | |
1639 | } | |
1640 | #[cfg(feature = "full")] | |
1641 | pub fn fold_foreign_item<F>(f: &mut F, node: ForeignItem) -> ForeignItem | |
1642 | where | |
1643 | F: Fold + ?Sized, | |
1644 | { | |
1645 | match node { | |
1646 | ForeignItem::Fn(_binding_0) => ForeignItem::Fn(f.fold_foreign_item_fn(_binding_0)), | |
1647 | ForeignItem::Static(_binding_0) => { | |
1648 | ForeignItem::Static(f.fold_foreign_item_static(_binding_0)) | |
1649 | } | |
1650 | ForeignItem::Type(_binding_0) => ForeignItem::Type(f.fold_foreign_item_type(_binding_0)), | |
1651 | ForeignItem::Macro(_binding_0) => ForeignItem::Macro(f.fold_foreign_item_macro(_binding_0)), | |
1652 | ForeignItem::Verbatim(_binding_0) => ForeignItem::Verbatim(_binding_0), | |
1653 | _ => unreachable!(), | |
1654 | } | |
1655 | } | |
1656 | #[cfg(feature = "full")] | |
1657 | pub fn fold_foreign_item_fn<F>(f: &mut F, node: ForeignItemFn) -> ForeignItemFn | |
1658 | where | |
1659 | F: Fold + ?Sized, | |
1660 | { | |
1661 | ForeignItemFn { | |
1662 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1663 | vis: f.fold_visibility(node.vis), | |
1664 | sig: f.fold_signature(node.sig), | |
1b1a35ee | 1665 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
1666 | } |
1667 | } | |
1668 | #[cfg(feature = "full")] | |
1669 | pub fn fold_foreign_item_macro<F>(f: &mut F, node: ForeignItemMacro) -> ForeignItemMacro | |
1670 | where | |
1671 | F: Fold + ?Sized, | |
1672 | { | |
1673 | ForeignItemMacro { | |
1674 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1675 | mac: f.fold_macro(node.mac), | |
1b1a35ee | 1676 | semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), |
e74abb32 XL |
1677 | } |
1678 | } | |
1679 | #[cfg(feature = "full")] | |
1680 | pub fn fold_foreign_item_static<F>(f: &mut F, node: ForeignItemStatic) -> ForeignItemStatic | |
1681 | where | |
1682 | F: Fold + ?Sized, | |
1683 | { | |
1684 | ForeignItemStatic { | |
1685 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1686 | vis: f.fold_visibility(node.vis), | |
1687 | static_token: Token![static](tokens_helper(f, &node.static_token.span)), | |
1688 | mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), | |
1689 | ident: f.fold_ident(node.ident), | |
1b1a35ee | 1690 | colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), |
e74abb32 | 1691 | ty: Box::new(f.fold_type(*node.ty)), |
1b1a35ee | 1692 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
1693 | } |
1694 | } | |
1695 | #[cfg(feature = "full")] | |
1696 | pub fn fold_foreign_item_type<F>(f: &mut F, node: ForeignItemType) -> ForeignItemType | |
1697 | where | |
1698 | F: Fold + ?Sized, | |
1699 | { | |
1700 | ForeignItemType { | |
1701 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1702 | vis: f.fold_visibility(node.vis), | |
1703 | type_token: Token![type](tokens_helper(f, &node.type_token.span)), | |
1704 | ident: f.fold_ident(node.ident), | |
1b1a35ee | 1705 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
1706 | } |
1707 | } | |
1708 | #[cfg(any(feature = "derive", feature = "full"))] | |
1709 | pub fn fold_generic_argument<F>(f: &mut F, node: GenericArgument) -> GenericArgument | |
1710 | where | |
1711 | F: Fold + ?Sized, | |
1712 | { | |
1713 | match node { | |
1714 | GenericArgument::Lifetime(_binding_0) => { | |
1715 | GenericArgument::Lifetime(f.fold_lifetime(_binding_0)) | |
1716 | } | |
1717 | GenericArgument::Type(_binding_0) => GenericArgument::Type(f.fold_type(_binding_0)), | |
1718 | GenericArgument::Binding(_binding_0) => { | |
1719 | GenericArgument::Binding(f.fold_binding(_binding_0)) | |
1720 | } | |
1721 | GenericArgument::Constraint(_binding_0) => { | |
1722 | GenericArgument::Constraint(f.fold_constraint(_binding_0)) | |
1723 | } | |
1724 | GenericArgument::Const(_binding_0) => GenericArgument::Const(f.fold_expr(_binding_0)), | |
1725 | } | |
1726 | } | |
1727 | #[cfg(feature = "full")] | |
1728 | pub fn fold_generic_method_argument<F>( | |
1729 | f: &mut F, | |
1730 | node: GenericMethodArgument, | |
1731 | ) -> GenericMethodArgument | |
1732 | where | |
1733 | F: Fold + ?Sized, | |
1734 | { | |
1735 | match node { | |
1736 | GenericMethodArgument::Type(_binding_0) => { | |
1737 | GenericMethodArgument::Type(f.fold_type(_binding_0)) | |
1738 | } | |
1739 | GenericMethodArgument::Const(_binding_0) => { | |
1740 | GenericMethodArgument::Const(f.fold_expr(_binding_0)) | |
1741 | } | |
1742 | } | |
1743 | } | |
1744 | #[cfg(any(feature = "derive", feature = "full"))] | |
1745 | pub fn fold_generic_param<F>(f: &mut F, node: GenericParam) -> GenericParam | |
1746 | where | |
1747 | F: Fold + ?Sized, | |
1748 | { | |
1749 | match node { | |
1750 | GenericParam::Type(_binding_0) => GenericParam::Type(f.fold_type_param(_binding_0)), | |
1751 | GenericParam::Lifetime(_binding_0) => { | |
1752 | GenericParam::Lifetime(f.fold_lifetime_def(_binding_0)) | |
1753 | } | |
1754 | GenericParam::Const(_binding_0) => GenericParam::Const(f.fold_const_param(_binding_0)), | |
1755 | } | |
1756 | } | |
1757 | #[cfg(any(feature = "derive", feature = "full"))] | |
1758 | pub fn fold_generics<F>(f: &mut F, node: Generics) -> Generics | |
1759 | where | |
1760 | F: Fold + ?Sized, | |
1761 | { | |
1762 | Generics { | |
1b1a35ee | 1763 | lt_token: (node.lt_token).map(|it| Token ! [<](tokens_helper(f, &it.spans))), |
e74abb32 | 1764 | params: FoldHelper::lift(node.params, |it| f.fold_generic_param(it)), |
1b1a35ee | 1765 | gt_token: (node.gt_token).map(|it| Token ! [>](tokens_helper(f, &it.spans))), |
e74abb32 XL |
1766 | where_clause: (node.where_clause).map(|it| f.fold_where_clause(it)), |
1767 | } | |
1768 | } | |
1769 | pub fn fold_ident<F>(f: &mut F, node: Ident) -> Ident | |
1770 | where | |
1771 | F: Fold + ?Sized, | |
1772 | { | |
1773 | let mut node = node; | |
1774 | let span = f.fold_span(node.span()); | |
1775 | node.set_span(span); | |
1776 | node | |
1777 | } | |
1778 | #[cfg(feature = "full")] | |
1779 | pub fn fold_impl_item<F>(f: &mut F, node: ImplItem) -> ImplItem | |
1780 | where | |
1781 | F: Fold + ?Sized, | |
1782 | { | |
1783 | match node { | |
1784 | ImplItem::Const(_binding_0) => ImplItem::Const(f.fold_impl_item_const(_binding_0)), | |
1785 | ImplItem::Method(_binding_0) => ImplItem::Method(f.fold_impl_item_method(_binding_0)), | |
1786 | ImplItem::Type(_binding_0) => ImplItem::Type(f.fold_impl_item_type(_binding_0)), | |
1787 | ImplItem::Macro(_binding_0) => ImplItem::Macro(f.fold_impl_item_macro(_binding_0)), | |
1788 | ImplItem::Verbatim(_binding_0) => ImplItem::Verbatim(_binding_0), | |
1789 | _ => unreachable!(), | |
1790 | } | |
1791 | } | |
1792 | #[cfg(feature = "full")] | |
1793 | pub fn fold_impl_item_const<F>(f: &mut F, node: ImplItemConst) -> ImplItemConst | |
1794 | where | |
1795 | F: Fold + ?Sized, | |
1796 | { | |
1797 | ImplItemConst { | |
1798 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1799 | vis: f.fold_visibility(node.vis), | |
1800 | defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))), | |
1801 | const_token: Token![const](tokens_helper(f, &node.const_token.span)), | |
1802 | ident: f.fold_ident(node.ident), | |
1b1a35ee | 1803 | colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), |
e74abb32 | 1804 | ty: f.fold_type(node.ty), |
1b1a35ee | 1805 | eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), |
e74abb32 | 1806 | expr: f.fold_expr(node.expr), |
1b1a35ee | 1807 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
1808 | } |
1809 | } | |
1810 | #[cfg(feature = "full")] | |
1811 | pub fn fold_impl_item_macro<F>(f: &mut F, node: ImplItemMacro) -> ImplItemMacro | |
1812 | where | |
1813 | F: Fold + ?Sized, | |
1814 | { | |
1815 | ImplItemMacro { | |
1816 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1817 | mac: f.fold_macro(node.mac), | |
1b1a35ee | 1818 | semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), |
e74abb32 XL |
1819 | } |
1820 | } | |
1821 | #[cfg(feature = "full")] | |
1822 | pub fn fold_impl_item_method<F>(f: &mut F, node: ImplItemMethod) -> ImplItemMethod | |
1823 | where | |
1824 | F: Fold + ?Sized, | |
1825 | { | |
1826 | ImplItemMethod { | |
1827 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1828 | vis: f.fold_visibility(node.vis), | |
1829 | defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))), | |
1830 | sig: f.fold_signature(node.sig), | |
1831 | block: f.fold_block(node.block), | |
1832 | } | |
1833 | } | |
1834 | #[cfg(feature = "full")] | |
1835 | pub fn fold_impl_item_type<F>(f: &mut F, node: ImplItemType) -> ImplItemType | |
1836 | where | |
1837 | F: Fold + ?Sized, | |
1838 | { | |
1839 | ImplItemType { | |
1840 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1841 | vis: f.fold_visibility(node.vis), | |
1842 | defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))), | |
1843 | type_token: Token![type](tokens_helper(f, &node.type_token.span)), | |
1844 | ident: f.fold_ident(node.ident), | |
1845 | generics: f.fold_generics(node.generics), | |
1b1a35ee | 1846 | eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), |
e74abb32 | 1847 | ty: f.fold_type(node.ty), |
1b1a35ee | 1848 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
1849 | } |
1850 | } | |
1851 | #[cfg(any(feature = "derive", feature = "full"))] | |
1852 | pub fn fold_index<F>(f: &mut F, node: Index) -> Index | |
1853 | where | |
1854 | F: Fold + ?Sized, | |
1855 | { | |
1856 | Index { | |
1857 | index: node.index, | |
1858 | span: f.fold_span(node.span), | |
1859 | } | |
1860 | } | |
1861 | #[cfg(feature = "full")] | |
1862 | pub fn fold_item<F>(f: &mut F, node: Item) -> Item | |
1863 | where | |
1864 | F: Fold + ?Sized, | |
1865 | { | |
1866 | match node { | |
1867 | Item::Const(_binding_0) => Item::Const(f.fold_item_const(_binding_0)), | |
1868 | Item::Enum(_binding_0) => Item::Enum(f.fold_item_enum(_binding_0)), | |
1869 | Item::ExternCrate(_binding_0) => Item::ExternCrate(f.fold_item_extern_crate(_binding_0)), | |
1870 | Item::Fn(_binding_0) => Item::Fn(f.fold_item_fn(_binding_0)), | |
1871 | Item::ForeignMod(_binding_0) => Item::ForeignMod(f.fold_item_foreign_mod(_binding_0)), | |
1872 | Item::Impl(_binding_0) => Item::Impl(f.fold_item_impl(_binding_0)), | |
1873 | Item::Macro(_binding_0) => Item::Macro(f.fold_item_macro(_binding_0)), | |
1874 | Item::Macro2(_binding_0) => Item::Macro2(f.fold_item_macro2(_binding_0)), | |
1875 | Item::Mod(_binding_0) => Item::Mod(f.fold_item_mod(_binding_0)), | |
1876 | Item::Static(_binding_0) => Item::Static(f.fold_item_static(_binding_0)), | |
1877 | Item::Struct(_binding_0) => Item::Struct(f.fold_item_struct(_binding_0)), | |
1878 | Item::Trait(_binding_0) => Item::Trait(f.fold_item_trait(_binding_0)), | |
1879 | Item::TraitAlias(_binding_0) => Item::TraitAlias(f.fold_item_trait_alias(_binding_0)), | |
1880 | Item::Type(_binding_0) => Item::Type(f.fold_item_type(_binding_0)), | |
1881 | Item::Union(_binding_0) => Item::Union(f.fold_item_union(_binding_0)), | |
1882 | Item::Use(_binding_0) => Item::Use(f.fold_item_use(_binding_0)), | |
1883 | Item::Verbatim(_binding_0) => Item::Verbatim(_binding_0), | |
1884 | _ => unreachable!(), | |
1885 | } | |
1886 | } | |
1887 | #[cfg(feature = "full")] | |
1888 | pub fn fold_item_const<F>(f: &mut F, node: ItemConst) -> ItemConst | |
1889 | where | |
1890 | F: Fold + ?Sized, | |
1891 | { | |
1892 | ItemConst { | |
1893 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1894 | vis: f.fold_visibility(node.vis), | |
1895 | const_token: Token![const](tokens_helper(f, &node.const_token.span)), | |
1896 | ident: f.fold_ident(node.ident), | |
1b1a35ee | 1897 | colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), |
e74abb32 | 1898 | ty: Box::new(f.fold_type(*node.ty)), |
1b1a35ee | 1899 | eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), |
e74abb32 | 1900 | expr: Box::new(f.fold_expr(*node.expr)), |
1b1a35ee | 1901 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
1902 | } |
1903 | } | |
1904 | #[cfg(feature = "full")] | |
1905 | pub fn fold_item_enum<F>(f: &mut F, node: ItemEnum) -> ItemEnum | |
1906 | where | |
1907 | F: Fold + ?Sized, | |
1908 | { | |
1909 | ItemEnum { | |
1910 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1911 | vis: f.fold_visibility(node.vis), | |
1912 | enum_token: Token![enum](tokens_helper(f, &node.enum_token.span)), | |
1913 | ident: f.fold_ident(node.ident), | |
1914 | generics: f.fold_generics(node.generics), | |
1915 | brace_token: Brace(tokens_helper(f, &node.brace_token.span)), | |
1916 | variants: FoldHelper::lift(node.variants, |it| f.fold_variant(it)), | |
1917 | } | |
1918 | } | |
1919 | #[cfg(feature = "full")] | |
1920 | pub fn fold_item_extern_crate<F>(f: &mut F, node: ItemExternCrate) -> ItemExternCrate | |
1921 | where | |
1922 | F: Fold + ?Sized, | |
1923 | { | |
1924 | ItemExternCrate { | |
1925 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1926 | vis: f.fold_visibility(node.vis), | |
1927 | extern_token: Token![extern](tokens_helper(f, &node.extern_token.span)), | |
1928 | crate_token: Token![crate](tokens_helper(f, &node.crate_token.span)), | |
1929 | ident: f.fold_ident(node.ident), | |
1930 | rename: (node.rename).map(|it| { | |
1931 | ( | |
1932 | Token![as](tokens_helper(f, &(it).0.span)), | |
1933 | f.fold_ident((it).1), | |
1934 | ) | |
1935 | }), | |
1b1a35ee | 1936 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
1937 | } |
1938 | } | |
1939 | #[cfg(feature = "full")] | |
1940 | pub fn fold_item_fn<F>(f: &mut F, node: ItemFn) -> ItemFn | |
1941 | where | |
1942 | F: Fold + ?Sized, | |
1943 | { | |
1944 | ItemFn { | |
1945 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1946 | vis: f.fold_visibility(node.vis), | |
1947 | sig: f.fold_signature(node.sig), | |
1948 | block: Box::new(f.fold_block(*node.block)), | |
1949 | } | |
1950 | } | |
1951 | #[cfg(feature = "full")] | |
1952 | pub fn fold_item_foreign_mod<F>(f: &mut F, node: ItemForeignMod) -> ItemForeignMod | |
1953 | where | |
1954 | F: Fold + ?Sized, | |
1955 | { | |
1956 | ItemForeignMod { | |
1957 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1958 | abi: f.fold_abi(node.abi), | |
1959 | brace_token: Brace(tokens_helper(f, &node.brace_token.span)), | |
1960 | items: FoldHelper::lift(node.items, |it| f.fold_foreign_item(it)), | |
1961 | } | |
1962 | } | |
1963 | #[cfg(feature = "full")] | |
1964 | pub fn fold_item_impl<F>(f: &mut F, node: ItemImpl) -> ItemImpl | |
1965 | where | |
1966 | F: Fold + ?Sized, | |
1967 | { | |
1968 | ItemImpl { | |
1969 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1970 | defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))), | |
1971 | unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))), | |
1972 | impl_token: Token![impl](tokens_helper(f, &node.impl_token.span)), | |
1973 | generics: f.fold_generics(node.generics), | |
1974 | trait_: (node.trait_).map(|it| { | |
1975 | ( | |
1976 | ((it).0).map(|it| Token![!](tokens_helper(f, &it.spans))), | |
1977 | f.fold_path((it).1), | |
1978 | Token![for](tokens_helper(f, &(it).2.span)), | |
1979 | ) | |
1980 | }), | |
1981 | self_ty: Box::new(f.fold_type(*node.self_ty)), | |
1982 | brace_token: Brace(tokens_helper(f, &node.brace_token.span)), | |
1983 | items: FoldHelper::lift(node.items, |it| f.fold_impl_item(it)), | |
1984 | } | |
1985 | } | |
1986 | #[cfg(feature = "full")] | |
1987 | pub fn fold_item_macro<F>(f: &mut F, node: ItemMacro) -> ItemMacro | |
1988 | where | |
1989 | F: Fold + ?Sized, | |
1990 | { | |
1991 | ItemMacro { | |
1992 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1993 | ident: (node.ident).map(|it| f.fold_ident(it)), | |
1994 | mac: f.fold_macro(node.mac), | |
1b1a35ee | 1995 | semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), |
e74abb32 XL |
1996 | } |
1997 | } | |
1998 | #[cfg(feature = "full")] | |
1999 | pub fn fold_item_macro2<F>(f: &mut F, node: ItemMacro2) -> ItemMacro2 | |
2000 | where | |
2001 | F: Fold + ?Sized, | |
2002 | { | |
2003 | ItemMacro2 { | |
2004 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2005 | vis: f.fold_visibility(node.vis), | |
2006 | macro_token: Token![macro](tokens_helper(f, &node.macro_token.span)), | |
2007 | ident: f.fold_ident(node.ident), | |
2008 | rules: node.rules, | |
2009 | } | |
2010 | } | |
2011 | #[cfg(feature = "full")] | |
2012 | pub fn fold_item_mod<F>(f: &mut F, node: ItemMod) -> ItemMod | |
2013 | where | |
2014 | F: Fold + ?Sized, | |
2015 | { | |
2016 | ItemMod { | |
2017 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2018 | vis: f.fold_visibility(node.vis), | |
2019 | mod_token: Token![mod](tokens_helper(f, &node.mod_token.span)), | |
2020 | ident: f.fold_ident(node.ident), | |
2021 | content: (node.content).map(|it| { | |
2022 | ( | |
2023 | Brace(tokens_helper(f, &(it).0.span)), | |
2024 | FoldHelper::lift((it).1, |it| f.fold_item(it)), | |
2025 | ) | |
2026 | }), | |
1b1a35ee | 2027 | semi: (node.semi).map(|it| Token ! [;](tokens_helper(f, &it.spans))), |
e74abb32 XL |
2028 | } |
2029 | } | |
2030 | #[cfg(feature = "full")] | |
2031 | pub fn fold_item_static<F>(f: &mut F, node: ItemStatic) -> ItemStatic | |
2032 | where | |
2033 | F: Fold + ?Sized, | |
2034 | { | |
2035 | ItemStatic { | |
2036 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2037 | vis: f.fold_visibility(node.vis), | |
2038 | static_token: Token![static](tokens_helper(f, &node.static_token.span)), | |
2039 | mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), | |
2040 | ident: f.fold_ident(node.ident), | |
1b1a35ee | 2041 | colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), |
e74abb32 | 2042 | ty: Box::new(f.fold_type(*node.ty)), |
1b1a35ee | 2043 | eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), |
e74abb32 | 2044 | expr: Box::new(f.fold_expr(*node.expr)), |
1b1a35ee | 2045 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
2046 | } |
2047 | } | |
2048 | #[cfg(feature = "full")] | |
2049 | pub fn fold_item_struct<F>(f: &mut F, node: ItemStruct) -> ItemStruct | |
2050 | where | |
2051 | F: Fold + ?Sized, | |
2052 | { | |
2053 | ItemStruct { | |
2054 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2055 | vis: f.fold_visibility(node.vis), | |
2056 | struct_token: Token![struct](tokens_helper(f, &node.struct_token.span)), | |
2057 | ident: f.fold_ident(node.ident), | |
2058 | generics: f.fold_generics(node.generics), | |
2059 | fields: f.fold_fields(node.fields), | |
1b1a35ee | 2060 | semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), |
e74abb32 XL |
2061 | } |
2062 | } | |
2063 | #[cfg(feature = "full")] | |
2064 | pub fn fold_item_trait<F>(f: &mut F, node: ItemTrait) -> ItemTrait | |
2065 | where | |
2066 | F: Fold + ?Sized, | |
2067 | { | |
2068 | ItemTrait { | |
2069 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2070 | vis: f.fold_visibility(node.vis), | |
2071 | unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))), | |
2072 | auto_token: (node.auto_token).map(|it| Token![auto](tokens_helper(f, &it.span))), | |
2073 | trait_token: Token![trait](tokens_helper(f, &node.trait_token.span)), | |
2074 | ident: f.fold_ident(node.ident), | |
2075 | generics: f.fold_generics(node.generics), | |
1b1a35ee | 2076 | colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), |
e74abb32 XL |
2077 | supertraits: FoldHelper::lift(node.supertraits, |it| f.fold_type_param_bound(it)), |
2078 | brace_token: Brace(tokens_helper(f, &node.brace_token.span)), | |
2079 | items: FoldHelper::lift(node.items, |it| f.fold_trait_item(it)), | |
2080 | } | |
2081 | } | |
2082 | #[cfg(feature = "full")] | |
2083 | pub fn fold_item_trait_alias<F>(f: &mut F, node: ItemTraitAlias) -> ItemTraitAlias | |
2084 | where | |
2085 | F: Fold + ?Sized, | |
2086 | { | |
2087 | ItemTraitAlias { | |
2088 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2089 | vis: f.fold_visibility(node.vis), | |
2090 | trait_token: Token![trait](tokens_helper(f, &node.trait_token.span)), | |
2091 | ident: f.fold_ident(node.ident), | |
2092 | generics: f.fold_generics(node.generics), | |
1b1a35ee | 2093 | eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), |
e74abb32 | 2094 | bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), |
1b1a35ee | 2095 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
2096 | } |
2097 | } | |
2098 | #[cfg(feature = "full")] | |
2099 | pub fn fold_item_type<F>(f: &mut F, node: ItemType) -> ItemType | |
2100 | where | |
2101 | F: Fold + ?Sized, | |
2102 | { | |
2103 | ItemType { | |
2104 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2105 | vis: f.fold_visibility(node.vis), | |
2106 | type_token: Token![type](tokens_helper(f, &node.type_token.span)), | |
2107 | ident: f.fold_ident(node.ident), | |
2108 | generics: f.fold_generics(node.generics), | |
1b1a35ee | 2109 | eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), |
e74abb32 | 2110 | ty: Box::new(f.fold_type(*node.ty)), |
1b1a35ee | 2111 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
2112 | } |
2113 | } | |
2114 | #[cfg(feature = "full")] | |
2115 | pub fn fold_item_union<F>(f: &mut F, node: ItemUnion) -> ItemUnion | |
2116 | where | |
2117 | F: Fold + ?Sized, | |
2118 | { | |
2119 | ItemUnion { | |
2120 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2121 | vis: f.fold_visibility(node.vis), | |
2122 | union_token: Token![union](tokens_helper(f, &node.union_token.span)), | |
2123 | ident: f.fold_ident(node.ident), | |
2124 | generics: f.fold_generics(node.generics), | |
2125 | fields: f.fold_fields_named(node.fields), | |
2126 | } | |
2127 | } | |
2128 | #[cfg(feature = "full")] | |
2129 | pub fn fold_item_use<F>(f: &mut F, node: ItemUse) -> ItemUse | |
2130 | where | |
2131 | F: Fold + ?Sized, | |
2132 | { | |
2133 | ItemUse { | |
2134 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2135 | vis: f.fold_visibility(node.vis), | |
2136 | use_token: Token![use](tokens_helper(f, &node.use_token.span)), | |
1b1a35ee | 2137 | leading_colon: (node.leading_colon).map(|it| Token ! [::](tokens_helper(f, &it.spans))), |
e74abb32 | 2138 | tree: f.fold_use_tree(node.tree), |
1b1a35ee | 2139 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
2140 | } |
2141 | } | |
2142 | #[cfg(feature = "full")] | |
2143 | pub fn fold_label<F>(f: &mut F, node: Label) -> Label | |
2144 | where | |
2145 | F: Fold + ?Sized, | |
2146 | { | |
2147 | Label { | |
2148 | name: f.fold_lifetime(node.name), | |
1b1a35ee | 2149 | colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), |
e74abb32 XL |
2150 | } |
2151 | } | |
2152 | pub fn fold_lifetime<F>(f: &mut F, node: Lifetime) -> Lifetime | |
2153 | where | |
2154 | F: Fold + ?Sized, | |
2155 | { | |
2156 | Lifetime { | |
2157 | apostrophe: f.fold_span(node.apostrophe), | |
2158 | ident: f.fold_ident(node.ident), | |
2159 | } | |
2160 | } | |
2161 | #[cfg(any(feature = "derive", feature = "full"))] | |
2162 | pub fn fold_lifetime_def<F>(f: &mut F, node: LifetimeDef) -> LifetimeDef | |
2163 | where | |
2164 | F: Fold + ?Sized, | |
2165 | { | |
2166 | LifetimeDef { | |
2167 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2168 | lifetime: f.fold_lifetime(node.lifetime), | |
1b1a35ee | 2169 | colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), |
e74abb32 XL |
2170 | bounds: FoldHelper::lift(node.bounds, |it| f.fold_lifetime(it)), |
2171 | } | |
2172 | } | |
e74abb32 XL |
2173 | pub fn fold_lit<F>(f: &mut F, node: Lit) -> Lit |
2174 | where | |
2175 | F: Fold + ?Sized, | |
2176 | { | |
2177 | match node { | |
2178 | Lit::Str(_binding_0) => Lit::Str(f.fold_lit_str(_binding_0)), | |
2179 | Lit::ByteStr(_binding_0) => Lit::ByteStr(f.fold_lit_byte_str(_binding_0)), | |
2180 | Lit::Byte(_binding_0) => Lit::Byte(f.fold_lit_byte(_binding_0)), | |
2181 | Lit::Char(_binding_0) => Lit::Char(f.fold_lit_char(_binding_0)), | |
2182 | Lit::Int(_binding_0) => Lit::Int(f.fold_lit_int(_binding_0)), | |
2183 | Lit::Float(_binding_0) => Lit::Float(f.fold_lit_float(_binding_0)), | |
2184 | Lit::Bool(_binding_0) => Lit::Bool(f.fold_lit_bool(_binding_0)), | |
2185 | Lit::Verbatim(_binding_0) => Lit::Verbatim(_binding_0), | |
2186 | } | |
2187 | } | |
e74abb32 XL |
2188 | pub fn fold_lit_bool<F>(f: &mut F, node: LitBool) -> LitBool |
2189 | where | |
2190 | F: Fold + ?Sized, | |
2191 | { | |
2192 | LitBool { | |
2193 | value: node.value, | |
2194 | span: f.fold_span(node.span), | |
2195 | } | |
2196 | } | |
e74abb32 XL |
2197 | pub fn fold_lit_byte<F>(f: &mut F, node: LitByte) -> LitByte |
2198 | where | |
2199 | F: Fold + ?Sized, | |
2200 | { | |
2201 | let span = f.fold_span(node.span()); | |
2202 | let mut node = node; | |
2203 | node.set_span(span); | |
2204 | node | |
2205 | } | |
e74abb32 XL |
2206 | pub fn fold_lit_byte_str<F>(f: &mut F, node: LitByteStr) -> LitByteStr |
2207 | where | |
2208 | F: Fold + ?Sized, | |
2209 | { | |
2210 | let span = f.fold_span(node.span()); | |
2211 | let mut node = node; | |
2212 | node.set_span(span); | |
2213 | node | |
2214 | } | |
e74abb32 XL |
2215 | pub fn fold_lit_char<F>(f: &mut F, node: LitChar) -> LitChar |
2216 | where | |
2217 | F: Fold + ?Sized, | |
2218 | { | |
2219 | let span = f.fold_span(node.span()); | |
2220 | let mut node = node; | |
2221 | node.set_span(span); | |
2222 | node | |
2223 | } | |
e74abb32 XL |
2224 | pub fn fold_lit_float<F>(f: &mut F, node: LitFloat) -> LitFloat |
2225 | where | |
2226 | F: Fold + ?Sized, | |
2227 | { | |
2228 | let span = f.fold_span(node.span()); | |
2229 | let mut node = node; | |
2230 | node.set_span(span); | |
2231 | node | |
2232 | } | |
e74abb32 XL |
2233 | pub fn fold_lit_int<F>(f: &mut F, node: LitInt) -> LitInt |
2234 | where | |
2235 | F: Fold + ?Sized, | |
2236 | { | |
2237 | let span = f.fold_span(node.span()); | |
2238 | let mut node = node; | |
2239 | node.set_span(span); | |
2240 | node | |
2241 | } | |
e74abb32 XL |
2242 | pub fn fold_lit_str<F>(f: &mut F, node: LitStr) -> LitStr |
2243 | where | |
2244 | F: Fold + ?Sized, | |
2245 | { | |
2246 | let span = f.fold_span(node.span()); | |
2247 | let mut node = node; | |
2248 | node.set_span(span); | |
2249 | node | |
2250 | } | |
2251 | #[cfg(feature = "full")] | |
2252 | pub fn fold_local<F>(f: &mut F, node: Local) -> Local | |
2253 | where | |
2254 | F: Fold + ?Sized, | |
2255 | { | |
2256 | Local { | |
2257 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2258 | let_token: Token![let](tokens_helper(f, &node.let_token.span)), | |
2259 | pat: f.fold_pat(node.pat), | |
2260 | init: (node.init).map(|it| { | |
2261 | ( | |
1b1a35ee | 2262 | Token ! [=](tokens_helper(f, &(it).0.spans)), |
e74abb32 XL |
2263 | Box::new(f.fold_expr(*(it).1)), |
2264 | ) | |
2265 | }), | |
1b1a35ee | 2266 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
2267 | } |
2268 | } | |
2269 | #[cfg(any(feature = "derive", feature = "full"))] | |
2270 | pub fn fold_macro<F>(f: &mut F, node: Macro) -> Macro | |
2271 | where | |
2272 | F: Fold + ?Sized, | |
2273 | { | |
2274 | Macro { | |
2275 | path: f.fold_path(node.path), | |
2276 | bang_token: Token![!](tokens_helper(f, &node.bang_token.spans)), | |
2277 | delimiter: f.fold_macro_delimiter(node.delimiter), | |
2278 | tokens: node.tokens, | |
2279 | } | |
2280 | } | |
2281 | #[cfg(any(feature = "derive", feature = "full"))] | |
2282 | pub fn fold_macro_delimiter<F>(f: &mut F, node: MacroDelimiter) -> MacroDelimiter | |
2283 | where | |
2284 | F: Fold + ?Sized, | |
2285 | { | |
2286 | match node { | |
2287 | MacroDelimiter::Paren(_binding_0) => { | |
2288 | MacroDelimiter::Paren(Paren(tokens_helper(f, &_binding_0.span))) | |
2289 | } | |
2290 | MacroDelimiter::Brace(_binding_0) => { | |
2291 | MacroDelimiter::Brace(Brace(tokens_helper(f, &_binding_0.span))) | |
2292 | } | |
2293 | MacroDelimiter::Bracket(_binding_0) => { | |
2294 | MacroDelimiter::Bracket(Bracket(tokens_helper(f, &_binding_0.span))) | |
2295 | } | |
2296 | } | |
2297 | } | |
2298 | #[cfg(any(feature = "derive", feature = "full"))] | |
2299 | pub fn fold_member<F>(f: &mut F, node: Member) -> Member | |
2300 | where | |
2301 | F: Fold + ?Sized, | |
2302 | { | |
2303 | match node { | |
2304 | Member::Named(_binding_0) => Member::Named(f.fold_ident(_binding_0)), | |
2305 | Member::Unnamed(_binding_0) => Member::Unnamed(f.fold_index(_binding_0)), | |
2306 | } | |
2307 | } | |
2308 | #[cfg(any(feature = "derive", feature = "full"))] | |
2309 | pub fn fold_meta<F>(f: &mut F, node: Meta) -> Meta | |
2310 | where | |
2311 | F: Fold + ?Sized, | |
2312 | { | |
2313 | match node { | |
2314 | Meta::Path(_binding_0) => Meta::Path(f.fold_path(_binding_0)), | |
2315 | Meta::List(_binding_0) => Meta::List(f.fold_meta_list(_binding_0)), | |
2316 | Meta::NameValue(_binding_0) => Meta::NameValue(f.fold_meta_name_value(_binding_0)), | |
2317 | } | |
2318 | } | |
2319 | #[cfg(any(feature = "derive", feature = "full"))] | |
2320 | pub fn fold_meta_list<F>(f: &mut F, node: MetaList) -> MetaList | |
2321 | where | |
2322 | F: Fold + ?Sized, | |
2323 | { | |
2324 | MetaList { | |
2325 | path: f.fold_path(node.path), | |
2326 | paren_token: Paren(tokens_helper(f, &node.paren_token.span)), | |
2327 | nested: FoldHelper::lift(node.nested, |it| f.fold_nested_meta(it)), | |
2328 | } | |
2329 | } | |
2330 | #[cfg(any(feature = "derive", feature = "full"))] | |
2331 | pub fn fold_meta_name_value<F>(f: &mut F, node: MetaNameValue) -> MetaNameValue | |
2332 | where | |
2333 | F: Fold + ?Sized, | |
2334 | { | |
2335 | MetaNameValue { | |
2336 | path: f.fold_path(node.path), | |
1b1a35ee | 2337 | eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), |
e74abb32 XL |
2338 | lit: f.fold_lit(node.lit), |
2339 | } | |
2340 | } | |
2341 | #[cfg(feature = "full")] | |
2342 | pub fn fold_method_turbofish<F>(f: &mut F, node: MethodTurbofish) -> MethodTurbofish | |
2343 | where | |
2344 | F: Fold + ?Sized, | |
2345 | { | |
2346 | MethodTurbofish { | |
1b1a35ee XL |
2347 | colon2_token: Token ! [::](tokens_helper(f, &node.colon2_token.spans)), |
2348 | lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)), | |
e74abb32 | 2349 | args: FoldHelper::lift(node.args, |it| f.fold_generic_method_argument(it)), |
1b1a35ee | 2350 | gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)), |
e74abb32 XL |
2351 | } |
2352 | } | |
2353 | #[cfg(any(feature = "derive", feature = "full"))] | |
2354 | pub fn fold_nested_meta<F>(f: &mut F, node: NestedMeta) -> NestedMeta | |
2355 | where | |
2356 | F: Fold + ?Sized, | |
2357 | { | |
2358 | match node { | |
2359 | NestedMeta::Meta(_binding_0) => NestedMeta::Meta(f.fold_meta(_binding_0)), | |
2360 | NestedMeta::Lit(_binding_0) => NestedMeta::Lit(f.fold_lit(_binding_0)), | |
2361 | } | |
2362 | } | |
2363 | #[cfg(any(feature = "derive", feature = "full"))] | |
2364 | pub fn fold_parenthesized_generic_arguments<F>( | |
2365 | f: &mut F, | |
2366 | node: ParenthesizedGenericArguments, | |
2367 | ) -> ParenthesizedGenericArguments | |
2368 | where | |
2369 | F: Fold + ?Sized, | |
2370 | { | |
2371 | ParenthesizedGenericArguments { | |
2372 | paren_token: Paren(tokens_helper(f, &node.paren_token.span)), | |
2373 | inputs: FoldHelper::lift(node.inputs, |it| f.fold_type(it)), | |
2374 | output: f.fold_return_type(node.output), | |
2375 | } | |
2376 | } | |
2377 | #[cfg(feature = "full")] | |
2378 | pub fn fold_pat<F>(f: &mut F, node: Pat) -> Pat | |
2379 | where | |
2380 | F: Fold + ?Sized, | |
2381 | { | |
2382 | match node { | |
2383 | Pat::Box(_binding_0) => Pat::Box(f.fold_pat_box(_binding_0)), | |
2384 | Pat::Ident(_binding_0) => Pat::Ident(f.fold_pat_ident(_binding_0)), | |
2385 | Pat::Lit(_binding_0) => Pat::Lit(f.fold_pat_lit(_binding_0)), | |
2386 | Pat::Macro(_binding_0) => Pat::Macro(f.fold_pat_macro(_binding_0)), | |
2387 | Pat::Or(_binding_0) => Pat::Or(f.fold_pat_or(_binding_0)), | |
2388 | Pat::Path(_binding_0) => Pat::Path(f.fold_pat_path(_binding_0)), | |
2389 | Pat::Range(_binding_0) => Pat::Range(f.fold_pat_range(_binding_0)), | |
2390 | Pat::Reference(_binding_0) => Pat::Reference(f.fold_pat_reference(_binding_0)), | |
2391 | Pat::Rest(_binding_0) => Pat::Rest(f.fold_pat_rest(_binding_0)), | |
2392 | Pat::Slice(_binding_0) => Pat::Slice(f.fold_pat_slice(_binding_0)), | |
2393 | Pat::Struct(_binding_0) => Pat::Struct(f.fold_pat_struct(_binding_0)), | |
2394 | Pat::Tuple(_binding_0) => Pat::Tuple(f.fold_pat_tuple(_binding_0)), | |
2395 | Pat::TupleStruct(_binding_0) => Pat::TupleStruct(f.fold_pat_tuple_struct(_binding_0)), | |
2396 | Pat::Type(_binding_0) => Pat::Type(f.fold_pat_type(_binding_0)), | |
2397 | Pat::Verbatim(_binding_0) => Pat::Verbatim(_binding_0), | |
2398 | Pat::Wild(_binding_0) => Pat::Wild(f.fold_pat_wild(_binding_0)), | |
2399 | _ => unreachable!(), | |
2400 | } | |
2401 | } | |
2402 | #[cfg(feature = "full")] | |
2403 | pub fn fold_pat_box<F>(f: &mut F, node: PatBox) -> PatBox | |
2404 | where | |
2405 | F: Fold + ?Sized, | |
2406 | { | |
2407 | PatBox { | |
2408 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2409 | box_token: Token![box](tokens_helper(f, &node.box_token.span)), | |
2410 | pat: Box::new(f.fold_pat(*node.pat)), | |
2411 | } | |
2412 | } | |
2413 | #[cfg(feature = "full")] | |
2414 | pub fn fold_pat_ident<F>(f: &mut F, node: PatIdent) -> PatIdent | |
2415 | where | |
2416 | F: Fold + ?Sized, | |
2417 | { | |
2418 | PatIdent { | |
2419 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2420 | by_ref: (node.by_ref).map(|it| Token![ref](tokens_helper(f, &it.span))), | |
2421 | mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), | |
2422 | ident: f.fold_ident(node.ident), | |
2423 | subpat: (node.subpat).map(|it| { | |
2424 | ( | |
1b1a35ee | 2425 | Token ! [@](tokens_helper(f, &(it).0.spans)), |
e74abb32 XL |
2426 | Box::new(f.fold_pat(*(it).1)), |
2427 | ) | |
2428 | }), | |
2429 | } | |
2430 | } | |
2431 | #[cfg(feature = "full")] | |
2432 | pub fn fold_pat_lit<F>(f: &mut F, node: PatLit) -> PatLit | |
2433 | where | |
2434 | F: Fold + ?Sized, | |
2435 | { | |
2436 | PatLit { | |
2437 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2438 | expr: Box::new(f.fold_expr(*node.expr)), | |
2439 | } | |
2440 | } | |
2441 | #[cfg(feature = "full")] | |
2442 | pub fn fold_pat_macro<F>(f: &mut F, node: PatMacro) -> PatMacro | |
2443 | where | |
2444 | F: Fold + ?Sized, | |
2445 | { | |
2446 | PatMacro { | |
2447 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2448 | mac: f.fold_macro(node.mac), | |
2449 | } | |
2450 | } | |
2451 | #[cfg(feature = "full")] | |
2452 | pub fn fold_pat_or<F>(f: &mut F, node: PatOr) -> PatOr | |
2453 | where | |
2454 | F: Fold + ?Sized, | |
2455 | { | |
2456 | PatOr { | |
2457 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1b1a35ee | 2458 | leading_vert: (node.leading_vert).map(|it| Token ! [|](tokens_helper(f, &it.spans))), |
e74abb32 XL |
2459 | cases: FoldHelper::lift(node.cases, |it| f.fold_pat(it)), |
2460 | } | |
2461 | } | |
2462 | #[cfg(feature = "full")] | |
2463 | pub fn fold_pat_path<F>(f: &mut F, node: PatPath) -> PatPath | |
2464 | where | |
2465 | F: Fold + ?Sized, | |
2466 | { | |
2467 | PatPath { | |
2468 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2469 | qself: (node.qself).map(|it| f.fold_qself(it)), | |
2470 | path: f.fold_path(node.path), | |
2471 | } | |
2472 | } | |
2473 | #[cfg(feature = "full")] | |
2474 | pub fn fold_pat_range<F>(f: &mut F, node: PatRange) -> PatRange | |
2475 | where | |
2476 | F: Fold + ?Sized, | |
2477 | { | |
2478 | PatRange { | |
2479 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2480 | lo: Box::new(f.fold_expr(*node.lo)), | |
2481 | limits: f.fold_range_limits(node.limits), | |
2482 | hi: Box::new(f.fold_expr(*node.hi)), | |
2483 | } | |
2484 | } | |
2485 | #[cfg(feature = "full")] | |
2486 | pub fn fold_pat_reference<F>(f: &mut F, node: PatReference) -> PatReference | |
2487 | where | |
2488 | F: Fold + ?Sized, | |
2489 | { | |
2490 | PatReference { | |
2491 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1b1a35ee | 2492 | and_token: Token ! [&](tokens_helper(f, &node.and_token.spans)), |
e74abb32 XL |
2493 | mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), |
2494 | pat: Box::new(f.fold_pat(*node.pat)), | |
2495 | } | |
2496 | } | |
2497 | #[cfg(feature = "full")] | |
2498 | pub fn fold_pat_rest<F>(f: &mut F, node: PatRest) -> PatRest | |
2499 | where | |
2500 | F: Fold + ?Sized, | |
2501 | { | |
2502 | PatRest { | |
2503 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2504 | dot2_token: Token![..](tokens_helper(f, &node.dot2_token.spans)), | |
2505 | } | |
2506 | } | |
2507 | #[cfg(feature = "full")] | |
2508 | pub fn fold_pat_slice<F>(f: &mut F, node: PatSlice) -> PatSlice | |
2509 | where | |
2510 | F: Fold + ?Sized, | |
2511 | { | |
2512 | PatSlice { | |
2513 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2514 | bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), | |
2515 | elems: FoldHelper::lift(node.elems, |it| f.fold_pat(it)), | |
2516 | } | |
2517 | } | |
2518 | #[cfg(feature = "full")] | |
2519 | pub fn fold_pat_struct<F>(f: &mut F, node: PatStruct) -> PatStruct | |
2520 | where | |
2521 | F: Fold + ?Sized, | |
2522 | { | |
2523 | PatStruct { | |
2524 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2525 | path: f.fold_path(node.path), | |
2526 | brace_token: Brace(tokens_helper(f, &node.brace_token.span)), | |
2527 | fields: FoldHelper::lift(node.fields, |it| f.fold_field_pat(it)), | |
2528 | dot2_token: (node.dot2_token).map(|it| Token![..](tokens_helper(f, &it.spans))), | |
2529 | } | |
2530 | } | |
2531 | #[cfg(feature = "full")] | |
2532 | pub fn fold_pat_tuple<F>(f: &mut F, node: PatTuple) -> PatTuple | |
2533 | where | |
2534 | F: Fold + ?Sized, | |
2535 | { | |
2536 | PatTuple { | |
2537 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2538 | paren_token: Paren(tokens_helper(f, &node.paren_token.span)), | |
2539 | elems: FoldHelper::lift(node.elems, |it| f.fold_pat(it)), | |
2540 | } | |
2541 | } | |
2542 | #[cfg(feature = "full")] | |
2543 | pub fn fold_pat_tuple_struct<F>(f: &mut F, node: PatTupleStruct) -> PatTupleStruct | |
2544 | where | |
2545 | F: Fold + ?Sized, | |
2546 | { | |
2547 | PatTupleStruct { | |
2548 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2549 | path: f.fold_path(node.path), | |
2550 | pat: f.fold_pat_tuple(node.pat), | |
2551 | } | |
2552 | } | |
2553 | #[cfg(feature = "full")] | |
2554 | pub fn fold_pat_type<F>(f: &mut F, node: PatType) -> PatType | |
2555 | where | |
2556 | F: Fold + ?Sized, | |
2557 | { | |
2558 | PatType { | |
2559 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2560 | pat: Box::new(f.fold_pat(*node.pat)), | |
1b1a35ee | 2561 | colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), |
e74abb32 XL |
2562 | ty: Box::new(f.fold_type(*node.ty)), |
2563 | } | |
2564 | } | |
2565 | #[cfg(feature = "full")] | |
2566 | pub fn fold_pat_wild<F>(f: &mut F, node: PatWild) -> PatWild | |
2567 | where | |
2568 | F: Fold + ?Sized, | |
2569 | { | |
2570 | PatWild { | |
2571 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2572 | underscore_token: Token![_](tokens_helper(f, &node.underscore_token.spans)), | |
2573 | } | |
2574 | } | |
2575 | #[cfg(any(feature = "derive", feature = "full"))] | |
2576 | pub fn fold_path<F>(f: &mut F, node: Path) -> Path | |
2577 | where | |
2578 | F: Fold + ?Sized, | |
2579 | { | |
2580 | Path { | |
1b1a35ee | 2581 | leading_colon: (node.leading_colon).map(|it| Token ! [::](tokens_helper(f, &it.spans))), |
e74abb32 XL |
2582 | segments: FoldHelper::lift(node.segments, |it| f.fold_path_segment(it)), |
2583 | } | |
2584 | } | |
2585 | #[cfg(any(feature = "derive", feature = "full"))] | |
2586 | pub fn fold_path_arguments<F>(f: &mut F, node: PathArguments) -> PathArguments | |
2587 | where | |
2588 | F: Fold + ?Sized, | |
2589 | { | |
2590 | match node { | |
2591 | PathArguments::None => PathArguments::None, | |
2592 | PathArguments::AngleBracketed(_binding_0) => { | |
2593 | PathArguments::AngleBracketed(f.fold_angle_bracketed_generic_arguments(_binding_0)) | |
2594 | } | |
2595 | PathArguments::Parenthesized(_binding_0) => { | |
2596 | PathArguments::Parenthesized(f.fold_parenthesized_generic_arguments(_binding_0)) | |
2597 | } | |
2598 | } | |
2599 | } | |
2600 | #[cfg(any(feature = "derive", feature = "full"))] | |
2601 | pub fn fold_path_segment<F>(f: &mut F, node: PathSegment) -> PathSegment | |
2602 | where | |
2603 | F: Fold + ?Sized, | |
2604 | { | |
2605 | PathSegment { | |
2606 | ident: f.fold_ident(node.ident), | |
2607 | arguments: f.fold_path_arguments(node.arguments), | |
2608 | } | |
2609 | } | |
2610 | #[cfg(any(feature = "derive", feature = "full"))] | |
2611 | pub fn fold_predicate_eq<F>(f: &mut F, node: PredicateEq) -> PredicateEq | |
2612 | where | |
2613 | F: Fold + ?Sized, | |
2614 | { | |
2615 | PredicateEq { | |
2616 | lhs_ty: f.fold_type(node.lhs_ty), | |
1b1a35ee | 2617 | eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), |
e74abb32 XL |
2618 | rhs_ty: f.fold_type(node.rhs_ty), |
2619 | } | |
2620 | } | |
2621 | #[cfg(any(feature = "derive", feature = "full"))] | |
2622 | pub fn fold_predicate_lifetime<F>(f: &mut F, node: PredicateLifetime) -> PredicateLifetime | |
2623 | where | |
2624 | F: Fold + ?Sized, | |
2625 | { | |
2626 | PredicateLifetime { | |
2627 | lifetime: f.fold_lifetime(node.lifetime), | |
1b1a35ee | 2628 | colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), |
e74abb32 XL |
2629 | bounds: FoldHelper::lift(node.bounds, |it| f.fold_lifetime(it)), |
2630 | } | |
2631 | } | |
2632 | #[cfg(any(feature = "derive", feature = "full"))] | |
2633 | pub fn fold_predicate_type<F>(f: &mut F, node: PredicateType) -> PredicateType | |
2634 | where | |
2635 | F: Fold + ?Sized, | |
2636 | { | |
2637 | PredicateType { | |
2638 | lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)), | |
2639 | bounded_ty: f.fold_type(node.bounded_ty), | |
1b1a35ee | 2640 | colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), |
e74abb32 XL |
2641 | bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), |
2642 | } | |
2643 | } | |
2644 | #[cfg(any(feature = "derive", feature = "full"))] | |
2645 | pub fn fold_qself<F>(f: &mut F, node: QSelf) -> QSelf | |
2646 | where | |
2647 | F: Fold + ?Sized, | |
2648 | { | |
2649 | QSelf { | |
1b1a35ee | 2650 | lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)), |
e74abb32 XL |
2651 | ty: Box::new(f.fold_type(*node.ty)), |
2652 | position: node.position, | |
2653 | as_token: (node.as_token).map(|it| Token![as](tokens_helper(f, &it.span))), | |
1b1a35ee | 2654 | gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)), |
e74abb32 XL |
2655 | } |
2656 | } | |
2657 | #[cfg(feature = "full")] | |
2658 | pub fn fold_range_limits<F>(f: &mut F, node: RangeLimits) -> RangeLimits | |
2659 | where | |
2660 | F: Fold + ?Sized, | |
2661 | { | |
2662 | match node { | |
2663 | RangeLimits::HalfOpen(_binding_0) => { | |
2664 | RangeLimits::HalfOpen(Token![..](tokens_helper(f, &_binding_0.spans))) | |
2665 | } | |
2666 | RangeLimits::Closed(_binding_0) => { | |
1b1a35ee | 2667 | RangeLimits::Closed(Token ! [..=](tokens_helper(f, &_binding_0.spans))) |
e74abb32 XL |
2668 | } |
2669 | } | |
2670 | } | |
2671 | #[cfg(feature = "full")] | |
2672 | pub fn fold_receiver<F>(f: &mut F, node: Receiver) -> Receiver | |
2673 | where | |
2674 | F: Fold + ?Sized, | |
2675 | { | |
2676 | Receiver { | |
2677 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2678 | reference: (node.reference).map(|it| { | |
2679 | ( | |
1b1a35ee | 2680 | Token ! [&](tokens_helper(f, &(it).0.spans)), |
e74abb32 XL |
2681 | ((it).1).map(|it| f.fold_lifetime(it)), |
2682 | ) | |
2683 | }), | |
2684 | mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), | |
2685 | self_token: Token![self](tokens_helper(f, &node.self_token.span)), | |
2686 | } | |
2687 | } | |
2688 | #[cfg(any(feature = "derive", feature = "full"))] | |
2689 | pub fn fold_return_type<F>(f: &mut F, node: ReturnType) -> ReturnType | |
2690 | where | |
2691 | F: Fold + ?Sized, | |
2692 | { | |
2693 | match node { | |
2694 | ReturnType::Default => ReturnType::Default, | |
2695 | ReturnType::Type(_binding_0, _binding_1) => ReturnType::Type( | |
1b1a35ee | 2696 | Token ! [->](tokens_helper(f, &_binding_0.spans)), |
e74abb32 XL |
2697 | Box::new(f.fold_type(*_binding_1)), |
2698 | ), | |
2699 | } | |
2700 | } | |
2701 | #[cfg(feature = "full")] | |
2702 | pub fn fold_signature<F>(f: &mut F, node: Signature) -> Signature | |
2703 | where | |
2704 | F: Fold + ?Sized, | |
2705 | { | |
2706 | Signature { | |
2707 | constness: (node.constness).map(|it| Token![const](tokens_helper(f, &it.span))), | |
2708 | asyncness: (node.asyncness).map(|it| Token![async](tokens_helper(f, &it.span))), | |
2709 | unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))), | |
2710 | abi: (node.abi).map(|it| f.fold_abi(it)), | |
2711 | fn_token: Token![fn](tokens_helper(f, &node.fn_token.span)), | |
2712 | ident: f.fold_ident(node.ident), | |
2713 | generics: f.fold_generics(node.generics), | |
2714 | paren_token: Paren(tokens_helper(f, &node.paren_token.span)), | |
2715 | inputs: FoldHelper::lift(node.inputs, |it| f.fold_fn_arg(it)), | |
2716 | variadic: (node.variadic).map(|it| f.fold_variadic(it)), | |
2717 | output: f.fold_return_type(node.output), | |
2718 | } | |
2719 | } | |
2720 | pub fn fold_span<F>(f: &mut F, node: Span) -> Span | |
2721 | where | |
2722 | F: Fold + ?Sized, | |
2723 | { | |
2724 | node | |
2725 | } | |
2726 | #[cfg(feature = "full")] | |
2727 | pub fn fold_stmt<F>(f: &mut F, node: Stmt) -> Stmt | |
2728 | where | |
2729 | F: Fold + ?Sized, | |
2730 | { | |
2731 | match node { | |
2732 | Stmt::Local(_binding_0) => Stmt::Local(f.fold_local(_binding_0)), | |
2733 | Stmt::Item(_binding_0) => Stmt::Item(f.fold_item(_binding_0)), | |
2734 | Stmt::Expr(_binding_0) => Stmt::Expr(f.fold_expr(_binding_0)), | |
2735 | Stmt::Semi(_binding_0, _binding_1) => Stmt::Semi( | |
2736 | f.fold_expr(_binding_0), | |
1b1a35ee | 2737 | Token ! [;](tokens_helper(f, &_binding_1.spans)), |
e74abb32 XL |
2738 | ), |
2739 | } | |
2740 | } | |
2741 | #[cfg(any(feature = "derive", feature = "full"))] | |
2742 | pub fn fold_trait_bound<F>(f: &mut F, node: TraitBound) -> TraitBound | |
2743 | where | |
2744 | F: Fold + ?Sized, | |
2745 | { | |
2746 | TraitBound { | |
2747 | paren_token: (node.paren_token).map(|it| Paren(tokens_helper(f, &it.span))), | |
2748 | modifier: f.fold_trait_bound_modifier(node.modifier), | |
2749 | lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)), | |
2750 | path: f.fold_path(node.path), | |
2751 | } | |
2752 | } | |
2753 | #[cfg(any(feature = "derive", feature = "full"))] | |
2754 | pub fn fold_trait_bound_modifier<F>(f: &mut F, node: TraitBoundModifier) -> TraitBoundModifier | |
2755 | where | |
2756 | F: Fold + ?Sized, | |
2757 | { | |
2758 | match node { | |
2759 | TraitBoundModifier::None => TraitBoundModifier::None, | |
2760 | TraitBoundModifier::Maybe(_binding_0) => { | |
1b1a35ee | 2761 | TraitBoundModifier::Maybe(Token ! [?](tokens_helper(f, &_binding_0.spans))) |
e74abb32 XL |
2762 | } |
2763 | } | |
2764 | } | |
2765 | #[cfg(feature = "full")] | |
2766 | pub fn fold_trait_item<F>(f: &mut F, node: TraitItem) -> TraitItem | |
2767 | where | |
2768 | F: Fold + ?Sized, | |
2769 | { | |
2770 | match node { | |
2771 | TraitItem::Const(_binding_0) => TraitItem::Const(f.fold_trait_item_const(_binding_0)), | |
2772 | TraitItem::Method(_binding_0) => TraitItem::Method(f.fold_trait_item_method(_binding_0)), | |
2773 | TraitItem::Type(_binding_0) => TraitItem::Type(f.fold_trait_item_type(_binding_0)), | |
2774 | TraitItem::Macro(_binding_0) => TraitItem::Macro(f.fold_trait_item_macro(_binding_0)), | |
2775 | TraitItem::Verbatim(_binding_0) => TraitItem::Verbatim(_binding_0), | |
2776 | _ => unreachable!(), | |
2777 | } | |
2778 | } | |
2779 | #[cfg(feature = "full")] | |
2780 | pub fn fold_trait_item_const<F>(f: &mut F, node: TraitItemConst) -> TraitItemConst | |
2781 | where | |
2782 | F: Fold + ?Sized, | |
2783 | { | |
2784 | TraitItemConst { | |
2785 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2786 | const_token: Token![const](tokens_helper(f, &node.const_token.span)), | |
2787 | ident: f.fold_ident(node.ident), | |
1b1a35ee | 2788 | colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), |
e74abb32 XL |
2789 | ty: f.fold_type(node.ty), |
2790 | default: (node.default).map(|it| { | |
2791 | ( | |
1b1a35ee | 2792 | Token ! [=](tokens_helper(f, &(it).0.spans)), |
e74abb32 XL |
2793 | f.fold_expr((it).1), |
2794 | ) | |
2795 | }), | |
1b1a35ee | 2796 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
2797 | } |
2798 | } | |
2799 | #[cfg(feature = "full")] | |
2800 | pub fn fold_trait_item_macro<F>(f: &mut F, node: TraitItemMacro) -> TraitItemMacro | |
2801 | where | |
2802 | F: Fold + ?Sized, | |
2803 | { | |
2804 | TraitItemMacro { | |
2805 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2806 | mac: f.fold_macro(node.mac), | |
1b1a35ee | 2807 | semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), |
e74abb32 XL |
2808 | } |
2809 | } | |
2810 | #[cfg(feature = "full")] | |
2811 | pub fn fold_trait_item_method<F>(f: &mut F, node: TraitItemMethod) -> TraitItemMethod | |
2812 | where | |
2813 | F: Fold + ?Sized, | |
2814 | { | |
2815 | TraitItemMethod { | |
2816 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2817 | sig: f.fold_signature(node.sig), | |
2818 | default: (node.default).map(|it| f.fold_block(it)), | |
1b1a35ee | 2819 | semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), |
e74abb32 XL |
2820 | } |
2821 | } | |
2822 | #[cfg(feature = "full")] | |
2823 | pub fn fold_trait_item_type<F>(f: &mut F, node: TraitItemType) -> TraitItemType | |
2824 | where | |
2825 | F: Fold + ?Sized, | |
2826 | { | |
2827 | TraitItemType { | |
2828 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2829 | type_token: Token![type](tokens_helper(f, &node.type_token.span)), | |
2830 | ident: f.fold_ident(node.ident), | |
2831 | generics: f.fold_generics(node.generics), | |
1b1a35ee | 2832 | colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), |
e74abb32 XL |
2833 | bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), |
2834 | default: (node.default).map(|it| { | |
2835 | ( | |
1b1a35ee | 2836 | Token ! [=](tokens_helper(f, &(it).0.spans)), |
e74abb32 XL |
2837 | f.fold_type((it).1), |
2838 | ) | |
2839 | }), | |
1b1a35ee | 2840 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
2841 | } |
2842 | } | |
2843 | #[cfg(any(feature = "derive", feature = "full"))] | |
2844 | pub fn fold_type<F>(f: &mut F, node: Type) -> Type | |
2845 | where | |
2846 | F: Fold + ?Sized, | |
2847 | { | |
2848 | match node { | |
2849 | Type::Array(_binding_0) => Type::Array(f.fold_type_array(_binding_0)), | |
2850 | Type::BareFn(_binding_0) => Type::BareFn(f.fold_type_bare_fn(_binding_0)), | |
2851 | Type::Group(_binding_0) => Type::Group(f.fold_type_group(_binding_0)), | |
2852 | Type::ImplTrait(_binding_0) => Type::ImplTrait(f.fold_type_impl_trait(_binding_0)), | |
2853 | Type::Infer(_binding_0) => Type::Infer(f.fold_type_infer(_binding_0)), | |
2854 | Type::Macro(_binding_0) => Type::Macro(f.fold_type_macro(_binding_0)), | |
2855 | Type::Never(_binding_0) => Type::Never(f.fold_type_never(_binding_0)), | |
2856 | Type::Paren(_binding_0) => Type::Paren(f.fold_type_paren(_binding_0)), | |
2857 | Type::Path(_binding_0) => Type::Path(f.fold_type_path(_binding_0)), | |
2858 | Type::Ptr(_binding_0) => Type::Ptr(f.fold_type_ptr(_binding_0)), | |
2859 | Type::Reference(_binding_0) => Type::Reference(f.fold_type_reference(_binding_0)), | |
2860 | Type::Slice(_binding_0) => Type::Slice(f.fold_type_slice(_binding_0)), | |
2861 | Type::TraitObject(_binding_0) => Type::TraitObject(f.fold_type_trait_object(_binding_0)), | |
2862 | Type::Tuple(_binding_0) => Type::Tuple(f.fold_type_tuple(_binding_0)), | |
2863 | Type::Verbatim(_binding_0) => Type::Verbatim(_binding_0), | |
2864 | _ => unreachable!(), | |
2865 | } | |
2866 | } | |
2867 | #[cfg(any(feature = "derive", feature = "full"))] | |
2868 | pub fn fold_type_array<F>(f: &mut F, node: TypeArray) -> TypeArray | |
2869 | where | |
2870 | F: Fold + ?Sized, | |
2871 | { | |
2872 | TypeArray { | |
2873 | bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), | |
2874 | elem: Box::new(f.fold_type(*node.elem)), | |
1b1a35ee | 2875 | semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), |
e74abb32 XL |
2876 | len: f.fold_expr(node.len), |
2877 | } | |
2878 | } | |
2879 | #[cfg(any(feature = "derive", feature = "full"))] | |
2880 | pub fn fold_type_bare_fn<F>(f: &mut F, node: TypeBareFn) -> TypeBareFn | |
2881 | where | |
2882 | F: Fold + ?Sized, | |
2883 | { | |
2884 | TypeBareFn { | |
2885 | lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)), | |
2886 | unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))), | |
2887 | abi: (node.abi).map(|it| f.fold_abi(it)), | |
2888 | fn_token: Token![fn](tokens_helper(f, &node.fn_token.span)), | |
2889 | paren_token: Paren(tokens_helper(f, &node.paren_token.span)), | |
2890 | inputs: FoldHelper::lift(node.inputs, |it| f.fold_bare_fn_arg(it)), | |
2891 | variadic: (node.variadic).map(|it| f.fold_variadic(it)), | |
2892 | output: f.fold_return_type(node.output), | |
2893 | } | |
2894 | } | |
2895 | #[cfg(any(feature = "derive", feature = "full"))] | |
2896 | pub fn fold_type_group<F>(f: &mut F, node: TypeGroup) -> TypeGroup | |
2897 | where | |
2898 | F: Fold + ?Sized, | |
2899 | { | |
2900 | TypeGroup { | |
2901 | group_token: Group(tokens_helper(f, &node.group_token.span)), | |
2902 | elem: Box::new(f.fold_type(*node.elem)), | |
2903 | } | |
2904 | } | |
2905 | #[cfg(any(feature = "derive", feature = "full"))] | |
2906 | pub fn fold_type_impl_trait<F>(f: &mut F, node: TypeImplTrait) -> TypeImplTrait | |
2907 | where | |
2908 | F: Fold + ?Sized, | |
2909 | { | |
2910 | TypeImplTrait { | |
2911 | impl_token: Token![impl](tokens_helper(f, &node.impl_token.span)), | |
2912 | bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), | |
2913 | } | |
2914 | } | |
2915 | #[cfg(any(feature = "derive", feature = "full"))] | |
2916 | pub fn fold_type_infer<F>(f: &mut F, node: TypeInfer) -> TypeInfer | |
2917 | where | |
2918 | F: Fold + ?Sized, | |
2919 | { | |
2920 | TypeInfer { | |
2921 | underscore_token: Token![_](tokens_helper(f, &node.underscore_token.spans)), | |
2922 | } | |
2923 | } | |
2924 | #[cfg(any(feature = "derive", feature = "full"))] | |
2925 | pub fn fold_type_macro<F>(f: &mut F, node: TypeMacro) -> TypeMacro | |
2926 | where | |
2927 | F: Fold + ?Sized, | |
2928 | { | |
2929 | TypeMacro { | |
2930 | mac: f.fold_macro(node.mac), | |
2931 | } | |
2932 | } | |
2933 | #[cfg(any(feature = "derive", feature = "full"))] | |
2934 | pub fn fold_type_never<F>(f: &mut F, node: TypeNever) -> TypeNever | |
2935 | where | |
2936 | F: Fold + ?Sized, | |
2937 | { | |
2938 | TypeNever { | |
2939 | bang_token: Token![!](tokens_helper(f, &node.bang_token.spans)), | |
2940 | } | |
2941 | } | |
2942 | #[cfg(any(feature = "derive", feature = "full"))] | |
2943 | pub fn fold_type_param<F>(f: &mut F, node: TypeParam) -> TypeParam | |
2944 | where | |
2945 | F: Fold + ?Sized, | |
2946 | { | |
2947 | TypeParam { | |
2948 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
2949 | ident: f.fold_ident(node.ident), | |
1b1a35ee | 2950 | colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), |
e74abb32 | 2951 | bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), |
1b1a35ee | 2952 | eq_token: (node.eq_token).map(|it| Token ! [=](tokens_helper(f, &it.spans))), |
e74abb32 XL |
2953 | default: (node.default).map(|it| f.fold_type(it)), |
2954 | } | |
2955 | } | |
2956 | #[cfg(any(feature = "derive", feature = "full"))] | |
2957 | pub fn fold_type_param_bound<F>(f: &mut F, node: TypeParamBound) -> TypeParamBound | |
2958 | where | |
2959 | F: Fold + ?Sized, | |
2960 | { | |
2961 | match node { | |
2962 | TypeParamBound::Trait(_binding_0) => TypeParamBound::Trait(f.fold_trait_bound(_binding_0)), | |
2963 | TypeParamBound::Lifetime(_binding_0) => { | |
2964 | TypeParamBound::Lifetime(f.fold_lifetime(_binding_0)) | |
2965 | } | |
2966 | } | |
2967 | } | |
2968 | #[cfg(any(feature = "derive", feature = "full"))] | |
2969 | pub fn fold_type_paren<F>(f: &mut F, node: TypeParen) -> TypeParen | |
2970 | where | |
2971 | F: Fold + ?Sized, | |
2972 | { | |
2973 | TypeParen { | |
2974 | paren_token: Paren(tokens_helper(f, &node.paren_token.span)), | |
2975 | elem: Box::new(f.fold_type(*node.elem)), | |
2976 | } | |
2977 | } | |
2978 | #[cfg(any(feature = "derive", feature = "full"))] | |
2979 | pub fn fold_type_path<F>(f: &mut F, node: TypePath) -> TypePath | |
2980 | where | |
2981 | F: Fold + ?Sized, | |
2982 | { | |
2983 | TypePath { | |
2984 | qself: (node.qself).map(|it| f.fold_qself(it)), | |
2985 | path: f.fold_path(node.path), | |
2986 | } | |
2987 | } | |
2988 | #[cfg(any(feature = "derive", feature = "full"))] | |
2989 | pub fn fold_type_ptr<F>(f: &mut F, node: TypePtr) -> TypePtr | |
2990 | where | |
2991 | F: Fold + ?Sized, | |
2992 | { | |
2993 | TypePtr { | |
1b1a35ee | 2994 | star_token: Token ! [*](tokens_helper(f, &node.star_token.spans)), |
e74abb32 XL |
2995 | const_token: (node.const_token).map(|it| Token![const](tokens_helper(f, &it.span))), |
2996 | mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), | |
2997 | elem: Box::new(f.fold_type(*node.elem)), | |
2998 | } | |
2999 | } | |
3000 | #[cfg(any(feature = "derive", feature = "full"))] | |
3001 | pub fn fold_type_reference<F>(f: &mut F, node: TypeReference) -> TypeReference | |
3002 | where | |
3003 | F: Fold + ?Sized, | |
3004 | { | |
3005 | TypeReference { | |
1b1a35ee | 3006 | and_token: Token ! [&](tokens_helper(f, &node.and_token.spans)), |
e74abb32 XL |
3007 | lifetime: (node.lifetime).map(|it| f.fold_lifetime(it)), |
3008 | mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), | |
3009 | elem: Box::new(f.fold_type(*node.elem)), | |
3010 | } | |
3011 | } | |
3012 | #[cfg(any(feature = "derive", feature = "full"))] | |
3013 | pub fn fold_type_slice<F>(f: &mut F, node: TypeSlice) -> TypeSlice | |
3014 | where | |
3015 | F: Fold + ?Sized, | |
3016 | { | |
3017 | TypeSlice { | |
3018 | bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), | |
3019 | elem: Box::new(f.fold_type(*node.elem)), | |
3020 | } | |
3021 | } | |
3022 | #[cfg(any(feature = "derive", feature = "full"))] | |
3023 | pub fn fold_type_trait_object<F>(f: &mut F, node: TypeTraitObject) -> TypeTraitObject | |
3024 | where | |
3025 | F: Fold + ?Sized, | |
3026 | { | |
3027 | TypeTraitObject { | |
3028 | dyn_token: (node.dyn_token).map(|it| Token![dyn](tokens_helper(f, &it.span))), | |
3029 | bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), | |
3030 | } | |
3031 | } | |
3032 | #[cfg(any(feature = "derive", feature = "full"))] | |
3033 | pub fn fold_type_tuple<F>(f: &mut F, node: TypeTuple) -> TypeTuple | |
3034 | where | |
3035 | F: Fold + ?Sized, | |
3036 | { | |
3037 | TypeTuple { | |
3038 | paren_token: Paren(tokens_helper(f, &node.paren_token.span)), | |
3039 | elems: FoldHelper::lift(node.elems, |it| f.fold_type(it)), | |
3040 | } | |
3041 | } | |
3042 | #[cfg(any(feature = "derive", feature = "full"))] | |
3043 | pub fn fold_un_op<F>(f: &mut F, node: UnOp) -> UnOp | |
3044 | where | |
3045 | F: Fold + ?Sized, | |
3046 | { | |
3047 | match node { | |
1b1a35ee | 3048 | UnOp::Deref(_binding_0) => UnOp::Deref(Token ! [*](tokens_helper(f, &_binding_0.spans))), |
e74abb32 | 3049 | UnOp::Not(_binding_0) => UnOp::Not(Token![!](tokens_helper(f, &_binding_0.spans))), |
1b1a35ee | 3050 | UnOp::Neg(_binding_0) => UnOp::Neg(Token ! [-](tokens_helper(f, &_binding_0.spans))), |
e74abb32 XL |
3051 | } |
3052 | } | |
3053 | #[cfg(feature = "full")] | |
3054 | pub fn fold_use_glob<F>(f: &mut F, node: UseGlob) -> UseGlob | |
3055 | where | |
3056 | F: Fold + ?Sized, | |
3057 | { | |
3058 | UseGlob { | |
1b1a35ee | 3059 | star_token: Token ! [*](tokens_helper(f, &node.star_token.spans)), |
e74abb32 XL |
3060 | } |
3061 | } | |
3062 | #[cfg(feature = "full")] | |
3063 | pub fn fold_use_group<F>(f: &mut F, node: UseGroup) -> UseGroup | |
3064 | where | |
3065 | F: Fold + ?Sized, | |
3066 | { | |
3067 | UseGroup { | |
3068 | brace_token: Brace(tokens_helper(f, &node.brace_token.span)), | |
3069 | items: FoldHelper::lift(node.items, |it| f.fold_use_tree(it)), | |
3070 | } | |
3071 | } | |
3072 | #[cfg(feature = "full")] | |
3073 | pub fn fold_use_name<F>(f: &mut F, node: UseName) -> UseName | |
3074 | where | |
3075 | F: Fold + ?Sized, | |
3076 | { | |
3077 | UseName { | |
3078 | ident: f.fold_ident(node.ident), | |
3079 | } | |
3080 | } | |
3081 | #[cfg(feature = "full")] | |
3082 | pub fn fold_use_path<F>(f: &mut F, node: UsePath) -> UsePath | |
3083 | where | |
3084 | F: Fold + ?Sized, | |
3085 | { | |
3086 | UsePath { | |
3087 | ident: f.fold_ident(node.ident), | |
1b1a35ee | 3088 | colon2_token: Token ! [::](tokens_helper(f, &node.colon2_token.spans)), |
e74abb32 XL |
3089 | tree: Box::new(f.fold_use_tree(*node.tree)), |
3090 | } | |
3091 | } | |
3092 | #[cfg(feature = "full")] | |
3093 | pub fn fold_use_rename<F>(f: &mut F, node: UseRename) -> UseRename | |
3094 | where | |
3095 | F: Fold + ?Sized, | |
3096 | { | |
3097 | UseRename { | |
3098 | ident: f.fold_ident(node.ident), | |
3099 | as_token: Token![as](tokens_helper(f, &node.as_token.span)), | |
3100 | rename: f.fold_ident(node.rename), | |
3101 | } | |
3102 | } | |
3103 | #[cfg(feature = "full")] | |
3104 | pub fn fold_use_tree<F>(f: &mut F, node: UseTree) -> UseTree | |
3105 | where | |
3106 | F: Fold + ?Sized, | |
3107 | { | |
3108 | match node { | |
3109 | UseTree::Path(_binding_0) => UseTree::Path(f.fold_use_path(_binding_0)), | |
3110 | UseTree::Name(_binding_0) => UseTree::Name(f.fold_use_name(_binding_0)), | |
3111 | UseTree::Rename(_binding_0) => UseTree::Rename(f.fold_use_rename(_binding_0)), | |
3112 | UseTree::Glob(_binding_0) => UseTree::Glob(f.fold_use_glob(_binding_0)), | |
3113 | UseTree::Group(_binding_0) => UseTree::Group(f.fold_use_group(_binding_0)), | |
3114 | } | |
3115 | } | |
3116 | #[cfg(any(feature = "derive", feature = "full"))] | |
3117 | pub fn fold_variadic<F>(f: &mut F, node: Variadic) -> Variadic | |
3118 | where | |
3119 | F: Fold + ?Sized, | |
3120 | { | |
3121 | Variadic { | |
3122 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
1b1a35ee | 3123 | dots: Token ! [...](tokens_helper(f, &node.dots.spans)), |
e74abb32 XL |
3124 | } |
3125 | } | |
3126 | #[cfg(any(feature = "derive", feature = "full"))] | |
3127 | pub fn fold_variant<F>(f: &mut F, node: Variant) -> Variant | |
3128 | where | |
3129 | F: Fold + ?Sized, | |
3130 | { | |
3131 | Variant { | |
3132 | attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), | |
3133 | ident: f.fold_ident(node.ident), | |
3134 | fields: f.fold_fields(node.fields), | |
3135 | discriminant: (node.discriminant).map(|it| { | |
3136 | ( | |
1b1a35ee | 3137 | Token ! [=](tokens_helper(f, &(it).0.spans)), |
e74abb32 XL |
3138 | f.fold_expr((it).1), |
3139 | ) | |
3140 | }), | |
3141 | } | |
3142 | } | |
3143 | #[cfg(any(feature = "derive", feature = "full"))] | |
3144 | pub fn fold_vis_crate<F>(f: &mut F, node: VisCrate) -> VisCrate | |
3145 | where | |
3146 | F: Fold + ?Sized, | |
3147 | { | |
3148 | VisCrate { | |
3149 | crate_token: Token![crate](tokens_helper(f, &node.crate_token.span)), | |
3150 | } | |
3151 | } | |
3152 | #[cfg(any(feature = "derive", feature = "full"))] | |
3153 | pub fn fold_vis_public<F>(f: &mut F, node: VisPublic) -> VisPublic | |
3154 | where | |
3155 | F: Fold + ?Sized, | |
3156 | { | |
3157 | VisPublic { | |
3158 | pub_token: Token![pub](tokens_helper(f, &node.pub_token.span)), | |
3159 | } | |
3160 | } | |
3161 | #[cfg(any(feature = "derive", feature = "full"))] | |
3162 | pub fn fold_vis_restricted<F>(f: &mut F, node: VisRestricted) -> VisRestricted | |
3163 | where | |
3164 | F: Fold + ?Sized, | |
3165 | { | |
3166 | VisRestricted { | |
3167 | pub_token: Token![pub](tokens_helper(f, &node.pub_token.span)), | |
3168 | paren_token: Paren(tokens_helper(f, &node.paren_token.span)), | |
3169 | in_token: (node.in_token).map(|it| Token![in](tokens_helper(f, &it.span))), | |
3170 | path: Box::new(f.fold_path(*node.path)), | |
3171 | } | |
3172 | } | |
3173 | #[cfg(any(feature = "derive", feature = "full"))] | |
3174 | pub fn fold_visibility<F>(f: &mut F, node: Visibility) -> Visibility | |
3175 | where | |
3176 | F: Fold + ?Sized, | |
3177 | { | |
3178 | match node { | |
3179 | Visibility::Public(_binding_0) => Visibility::Public(f.fold_vis_public(_binding_0)), | |
3180 | Visibility::Crate(_binding_0) => Visibility::Crate(f.fold_vis_crate(_binding_0)), | |
3181 | Visibility::Restricted(_binding_0) => { | |
3182 | Visibility::Restricted(f.fold_vis_restricted(_binding_0)) | |
3183 | } | |
3184 | Visibility::Inherited => Visibility::Inherited, | |
3185 | } | |
3186 | } | |
3187 | #[cfg(any(feature = "derive", feature = "full"))] | |
3188 | pub fn fold_where_clause<F>(f: &mut F, node: WhereClause) -> WhereClause | |
3189 | where | |
3190 | F: Fold + ?Sized, | |
3191 | { | |
3192 | WhereClause { | |
3193 | where_token: Token![where](tokens_helper(f, &node.where_token.span)), | |
3194 | predicates: FoldHelper::lift(node.predicates, |it| f.fold_where_predicate(it)), | |
3195 | } | |
3196 | } | |
3197 | #[cfg(any(feature = "derive", feature = "full"))] | |
3198 | pub fn fold_where_predicate<F>(f: &mut F, node: WherePredicate) -> WherePredicate | |
3199 | where | |
3200 | F: Fold + ?Sized, | |
3201 | { | |
3202 | match node { | |
3203 | WherePredicate::Type(_binding_0) => WherePredicate::Type(f.fold_predicate_type(_binding_0)), | |
3204 | WherePredicate::Lifetime(_binding_0) => { | |
3205 | WherePredicate::Lifetime(f.fold_predicate_lifetime(_binding_0)) | |
3206 | } | |
3207 | WherePredicate::Eq(_binding_0) => WherePredicate::Eq(f.fold_predicate_eq(_binding_0)), | |
3208 | } | |
3209 | } |