1use proc_macro2::{Group, Literal, Punct, TokenStream, TokenTree};
2use syn::token::{
3 Abstract, And, AndAnd, AndEq, As, Async, At, Auto, Await, Become, Break, Caret, CaretEq, Colon,
4 Comma, Const, Continue, Crate, Do, Dollar, Dot, DotDot, DotDotDot, DotDotEq, Dyn, Else, Enum,
5 Eq, EqEq, Extern, FatArrow, Final, Fn, For, Ge, Gt, If, Impl, In, LArrow, Le, Let, Loop, Lt,
6 Match, Minus, MinusEq, Mod, Move, Mut, Ne, Not, Or, OrEq, OrOr, Override, PathSep, Percent,
7 PercentEq, Plus, PlusEq, Pound, Priv, Pub, Question, RArrow, Ref, Return, SelfType, SelfValue,
8 Semi, Shl, ShlEq, Shr, ShrEq, Slash, SlashEq, Star, StarEq, Static, Struct, Super, Tilde,
9 Trait, Try, Typeof, Underscore, Union, Unsafe, Unsized, Use, Virtual, Where, While, Yield,
10};
11use syn::{
12 Abi, AngleBracketedGenericArguments, BareFnArg, BinOp, BoundLifetimes, ConstParam, DeriveInput,
13 Expr, FieldsNamed, FieldsUnnamed, GenericArgument, GenericParam, Generics, Ident, Index,
14 Lifetime, Lit, LitBool, LitByteStr, LitChar, LitFloat, LitInt, LitStr, Member, Meta, MetaList,
15 MetaNameValue, ParenthesizedGenericArguments, Path, PathSegment, ReturnType, TraitBound,
16 TraitBoundModifier, Type, TypeArray, TypeBareFn, TypeGroup, TypeImplTrait, TypeInfer,
17 TypeMacro, TypeNever, TypeParam, TypeParamBound, TypeParen, TypePath, TypePtr, TypeReference,
18 TypeSlice, TypeTraitObject, TypeTuple, UnOp, Variant, Visibility, WhereClause, WherePredicate,
19};
20
21use crate::parsing::*;
22use crate::*;
23
24#[macro_export]
27macro_rules! impl_Attribute_for_Parse_and_ToTokens {
28 ($($type:ty),+ $(,)?) => {$(
29 impl $crate::parsing::AttributeBase for $type {
30 type Partial = Self;
31 }
32
33 impl $crate::parsing::AttributeValue for $type {
34 fn parse_value(input: $crate::__private::syn::parse::ParseStream) -> $crate::__private::syn::Result<$crate::parsing::SpannedValue<Self::Partial>> {
35 input.parse().map($crate::parsing::SpannedValue::from_to_tokens)
36 }
37 }
38
39 impl $crate::parsing::PositionalValue for $type {}
40
41 )*}
42}
43
44impl AttributeBase for TokenStream {
45 type Partial = Self;
46}
47
48impl AttributeMeta for TokenStream {
49 fn parse_inner(input: ParseStream) -> Result<Self::Partial> {
50 input.parse()
51 }
52}
53
54impl_Attribute_for_Parse_and_ToTokens!(Type);
105impl_Attribute_for_Parse_and_ToTokens!(Path);
106impl_Attribute_for_Parse_and_ToTokens!(Lit);
107impl_Attribute_for_Parse_and_ToTokens![LitStr, LitByteStr, LitChar, LitInt, LitFloat, LitBool];
108impl_Attribute_for_Parse_and_ToTokens!(Expr);
109impl_Attribute_for_Parse_and_ToTokens![TokenTree, Group, Punct, Literal];
110
111impl_Attribute_for_Parse_and_ToTokens![
123 Abi,
124 Abstract,
125 Plus,
126 PlusEq,
127 And,
128 AndAnd,
129 AndEq,
130 AngleBracketedGenericArguments,
131 As,
132 Async,
133 At,
134 Auto,
135 Await,
136 Not,
137 BareFnArg,
138 Become,
139 BinOp,
140 BoundLifetimes,
141 Break,
142 Caret,
143 CaretEq,
144 Colon,
145 PathSep,
146 Comma,
147 Const,
148 ConstParam,
149 Continue,
150 Crate,
151 DeriveInput,
152 Slash,
153 SlashEq,
154 Do,
155 Dollar,
156 Dot,
157 DotDot,
158 DotDotDot,
159 DotDotEq,
160 Dyn,
161 Else,
162 Enum,
163 Eq,
164 EqEq,
165 Extern,
166 FatArrow,
167 FieldsNamed,
168 FieldsUnnamed,
169 Final,
170 Fn,
171 For,
172 Ge,
173 GenericArgument,
174 GenericParam,
175 Generics,
176 Gt,
177 Ident,
178 If,
179 Impl,
180 In,
181 Index,
182 LArrow,
183 Le,
184 Let,
185 Lifetime,
186 Loop,
187 Lt,
188 Match,
189 Member,
190 Meta,
191 MetaList,
192 MetaNameValue,
193 Mod,
194 Move,
195 StarEq,
196 Mut,
197 Ne,
198 Or,
199 OrEq,
200 OrOr,
201 Override,
202 ParenthesizedGenericArguments,
203 PathSegment,
204 Pound,
205 Priv,
206 Pub,
207 Question,
208 RArrow,
209 Ref,
210 Percent,
211 PercentEq,
212 Return,
213 ReturnType,
214 SelfType,
215 SelfValue,
216 Semi,
217 Shl,
218 ShlEq,
219 Shr,
220 ShrEq,
221 Star,
222 Static,
223 Struct,
224 Minus,
225 MinusEq,
226 Super,
227 Tilde,
228 Trait,
229 TraitBound,
230 TraitBoundModifier,
231 Try,
232 TypeArray,
233 TypeBareFn,
234 TypeGroup,
235 TypeImplTrait,
236 TypeInfer,
237 TypeMacro,
238 TypeNever,
239 TypeParam,
240 TypeParamBound,
241 TypeParen,
242 TypePath,
243 TypePtr,
244 TypeReference,
245 TypeSlice,
246 TypeTraitObject,
247 TypeTuple,
248 Typeof,
249 UnOp,
250 Underscore,
251 Union,
252 Unsafe,
253 Unsized,
254 Use,
255 Variant,
256 Virtual,
257 Visibility,
258 Where,
259 WhereClause,
260 WherePredicate,
261 While,
262 Yield,
263 syn::Macro,
264 syn::token::Box,
265 syn::token::Default,
266 syn::token::Macro,
267 syn::token::Type,
268];
269
270#[cfg(feature = "syn-full")]
271mod syn_full {
272 use syn::{
273 Arm, Block, ExprArray, ExprAssign, ExprAsync, ExprBinary, ExprBlock, ExprBreak, ExprCall,
274 ExprCast, ExprClosure, ExprContinue, ExprField, ExprForLoop, ExprIf, ExprIndex, ExprLet,
275 ExprLit, ExprLoop, ExprMacro, ExprMatch, ExprMethodCall, ExprParen, ExprPath, ExprRange,
276 ExprReference, ExprRepeat, ExprReturn, ExprStruct, ExprTry, ExprTryBlock, ExprTuple,
277 ExprUnary, ExprUnsafe, ExprWhile, ExprYield, FieldValue, File, FnArg, ForeignItem,
278 ForeignItemFn, ForeignItemMacro, ForeignItemStatic, ForeignItemType, ImplItem,
279 ImplItemConst, ImplItemMacro, ImplItemType, Item, ItemConst, ItemEnum, ItemExternCrate,
280 ItemFn, ItemForeignMod, ItemImpl, ItemMacro, ItemMod, ItemStatic, ItemStruct, ItemTrait,
281 ItemTraitAlias, ItemType, ItemUnion, ItemUse, Label, RangeLimits, Receiver, Signature,
282 Stmt, TraitItem, TraitItemConst, TraitItemMacro, TraitItemType, UseTree,
283 };
284
285 use super::*;
286
287 impl_Attribute_for_Parse_and_ToTokens![
288 Arm,
289 Block,
290 ExprArray,
291 ExprAssign,
292 ExprAsync,
293 ExprBinary,
294 ExprBlock,
295 ExprBreak,
296 ExprCall,
297 ExprCast,
298 ExprClosure,
299 ExprContinue,
300 ExprField,
301 ExprForLoop,
302 ExprIf,
303 ExprIndex,
304 ExprLet,
305 ExprLit,
306 ExprLoop,
307 ExprMacro,
308 ExprMatch,
309 ExprMethodCall,
310 ExprParen,
311 ExprPath,
312 ExprRange,
313 ExprReference,
314 ExprRepeat,
315 ExprReturn,
316 ExprStruct,
317 ExprTry,
318 ExprTryBlock,
319 ExprTuple,
320 ExprUnary,
321 ExprUnsafe,
322 ExprWhile,
323 ExprYield,
324 FieldValue,
325 File,
326 FnArg,
327 ForeignItem,
328 ForeignItemFn,
329 ForeignItemMacro,
330 ForeignItemStatic,
331 ForeignItemType,
332 ImplItem,
333 ImplItemConst,
334 ImplItemMacro,
335 ImplItemType,
336 Item,
337 ItemConst,
338 ItemEnum,
339 ItemExternCrate,
340 ItemFn,
341 ItemForeignMod,
342 ItemImpl,
343 ItemMacro,
344 ItemMod,
345 ItemStatic,
346 ItemStruct,
347 ItemTrait,
348 ItemTraitAlias,
349 ItemType,
350 ItemUnion,
351 ItemUse,
352 Label,
353 RangeLimits,
354 Receiver,
355 Signature,
356 Stmt,
357 TraitItem,
358 TraitItemConst,
359 TraitItemMacro,
360 TraitItemType,
361 UseTree,
362 ];
363}