]> git.lizzy.rs Git - rust.git/blob - src/test/ui/check-cfg/mix.rs
Move some tests with compare-mode=nll output to revisions
[rust.git] / src / test / ui / check-cfg / mix.rs
1 // This test checks the combination of well known names, their activation via names(), the usage of
2 // partial values() with a --cfg and test that we also correctly lint on the `cfg!` macro and
3 // `cfg_attr` attribute.
4 //
5 // check-pass
6 // compile-flags: --check-cfg=names() --check-cfg=values(feature,"foo") --cfg feature="bar" -Z unstable-options
7
8 #[cfg(windows)]
9 fn do_windows_stuff() {}
10
11 #[cfg(widnows)]
12 //~^ WARNING unexpected `cfg` condition name
13 fn do_windows_stuff() {}
14
15 #[cfg(feature = "foo")]
16 fn use_foo() {}
17
18 #[cfg(feature = "bar")]
19 fn use_bar() {}
20
21 #[cfg(feature = "zebra")]
22 //~^ WARNING unexpected `cfg` condition value
23 fn use_zebra() {}
24
25 #[cfg_attr(uu, test)]
26 //~^ WARNING unexpected `cfg` condition name
27 fn do_test() {}
28
29 #[cfg_attr(feature = "foo", no_mangle)]
30 fn do_test_foo() {}
31
32 fn test_cfg_macro() {
33     cfg!(windows);
34     cfg!(widnows);
35     //~^ WARNING unexpected `cfg` condition name
36     cfg!(feature = "foo");
37     cfg!(feature = "bar");
38     cfg!(feature = "zebra");
39     //~^ WARNING unexpected `cfg` condition value
40     cfg!(xxx = "foo");
41     //~^ WARNING unexpected `cfg` condition name
42     cfg!(xxx);
43     //~^ WARNING unexpected `cfg` condition name
44     cfg!(any(xxx, windows));
45     //~^ WARNING unexpected `cfg` condition name
46     cfg!(any(feature = "bad", windows));
47     //~^ WARNING unexpected `cfg` condition value
48     cfg!(any(windows, xxx));
49     //~^ WARNING unexpected `cfg` condition name
50     cfg!(all(unix, xxx));
51     //~^ WARNING unexpected `cfg` condition name
52     cfg!(all(aa, bb));
53     //~^ WARNING unexpected `cfg` condition name
54     //~| WARNING unexpected `cfg` condition name
55     cfg!(any(aa, bb));
56     //~^ WARNING unexpected `cfg` condition name
57     //~| WARNING unexpected `cfg` condition name
58     cfg!(any(unix, feature = "zebra"));
59     //~^ WARNING unexpected `cfg` condition value
60     cfg!(any(xxx, feature = "zebra"));
61     //~^ WARNING unexpected `cfg` condition name
62     //~| WARNING unexpected `cfg` condition value
63     cfg!(any(xxx, unix, xxx));
64     //~^ WARNING unexpected `cfg` condition name
65     //~| WARNING unexpected `cfg` condition name
66     cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
67     //~^ WARNING unexpected `cfg` condition value
68     //~| WARNING unexpected `cfg` condition value
69     //~| WARNING unexpected `cfg` condition value
70 }
71
72 fn main() {}