]> git.lizzy.rs Git - rust.git/blob - tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs
Rollup merge of #107700 - jyn514:tools-builder, r=Mark-Simulacrum
[rust.git] / tests / ui / conditional-compilation / cfg-attr-syntax-validation.rs
1 #[cfg] //~ ERROR `cfg` is not followed by parentheses
2 struct S1;
3
4 #[cfg = 10] //~ ERROR `cfg` is not followed by parentheses
5 struct S2;
6
7 #[cfg()] //~ ERROR `cfg` predicate is not specified
8 struct S3;
9
10 #[cfg(a, b)] //~ ERROR multiple `cfg` predicates are specified
11 struct S4;
12
13 #[cfg("str")] //~ ERROR `cfg` predicate key cannot be a literal
14 struct S5;
15
16 #[cfg(a::b)] //~ ERROR `cfg` predicate key must be an identifier
17 struct S6;
18
19 #[cfg(a())] //~ ERROR invalid predicate `a`
20 struct S7;
21
22 #[cfg(a = 10)] //~ ERROR literal in `cfg` predicate value must be a string
23 struct S8;
24
25 #[cfg(a = b"hi")]  //~ ERROR literal in `cfg` predicate value must be a string
26 struct S9;
27
28 macro_rules! generate_s10 {
29     ($expr: expr) => {
30         #[cfg(feature = $expr)]
31         //~^ ERROR expected unsuffixed literal or identifier, found `concat!("nonexistent")`
32         //~| ERROR expected unsuffixed literal or identifier, found `concat!("nonexistent")`
33         struct S10;
34     }
35 }
36
37 generate_s10!(concat!("nonexistent"));
38
39 fn main() {}