]> git.lizzy.rs Git - rust.git/blob - src/test/ui/conditional-compilation/cfg-attr-parse.rs
Auto merge of #53918 - Havvy:doc-sort-by, r=GuillaumeGomez
[rust.git] / src / test / ui / conditional-compilation / cfg-attr-parse.rs
1 // Parse `cfg_attr` with varying numbers of attributes and trailing commas
2
3 #![feature(cfg_attr_multi)]
4
5 // Completely empty `cfg_attr` input
6 #[cfg_attr()] //~ error: expected identifier, found `)`
7 struct NoConfigurationPredicate;
8
9 // Zero attributes, zero trailing comma (comma manatory here)
10 #[cfg_attr(all())] //~ error: expected `,`, found `)`
11 struct A0C0;
12
13 // Zero attributes, one trailing comma
14 #[cfg_attr(all(),)] // Ok
15 struct A0C1;
16
17 // Zero attributes, two trailing commas
18 #[cfg_attr(all(),,)] //~ ERROR expected identifier
19 struct A0C2;
20
21 // One attribute, no trailing comma
22 #[cfg_attr(all(), must_use)] // Ok
23 struct A1C0;
24
25 // One attribute, one trailing comma
26 #[cfg_attr(all(), must_use,)] // Ok
27 struct A1C1;
28
29 // One attribute, two trailing commas
30 #[cfg_attr(all(), must_use,,)] //~ ERROR expected identifier
31 struct A1C2;
32
33 // Two attributes, no trailing comma
34 #[cfg_attr(all(), must_use, deprecated)] // Ok
35 struct A2C0;
36
37 // Two attributes, one trailing comma
38 #[cfg_attr(all(), must_use, deprecated,)] // Ok
39 struct A2C1;
40
41 // Two attributes, two trailing commas
42 #[cfg_attr(all(), must_use, deprecated,,)] //~ ERROR expected identifier
43 struct A2C2;
44
45 fn main() {}