1 // Parse `cfg_attr` with varying numbers of attributes and trailing commas
2 
3 // Completely empty `cfg_attr` input
4 #[cfg_attr()] //~ error: malformed `cfg_attr` attribute input
5 struct NoConfigurationPredicate;
6 
7 // Zero attributes, zero trailing comma (comma manatory here)
8 #[cfg_attr(all())] //~ error: expected `,`, found end of `cfg_attr`
9 struct A0C0;
10 
11 // Zero attributes, one trailing comma
12 #[cfg_attr(all(),)] // Ok
13 struct A0C1;
14 
15 // Zero attributes, two trailing commas
16 #[cfg_attr(all(),,)] //~ ERROR expected identifier
17 struct A0C2;
18 
19 // One attribute, no trailing comma
20 #[cfg_attr(all(), must_use)] // Ok
21 struct A1C0;
22 
23 // One attribute, one trailing comma
24 #[cfg_attr(all(), must_use,)] // Ok
25 struct A1C1;
26 
27 // One attribute, two trailing commas
28 #[cfg_attr(all(), must_use,,)] //~ ERROR expected identifier
29 struct A1C2;
30 
31 // Two attributes, no trailing comma
32 #[cfg_attr(all(), must_use, deprecated)] // Ok
33 struct A2C0;
34 
35 // Two attributes, one trailing comma
36 #[cfg_attr(all(), must_use, deprecated,)] // Ok
37 struct A2C1;
38 
39 // Two attributes, two trailing commas
40 #[cfg_attr(all(), must_use, deprecated,,)] //~ ERROR expected identifier
41 struct A2C2;
42 
43 // Wrong delimiter `[`
44 #[cfg_attr[all(),,]]
45 //~^ ERROR wrong `cfg_attr` delimiters
46 //~| ERROR expected identifier, found `,`
47 struct BracketZero;
48 
49 // Wrong delimiter `{`
50 #[cfg_attr{all(),,}]
51 //~^ ERROR wrong `cfg_attr` delimiters
52 //~| ERROR expected identifier, found `,`
53 struct BraceZero;
54 
main()55 fn main() {}
56