|
1 | | -// This test check that we lint on non well known values and that we don't lint on well known |
2 | | -// values |
| 1 | +// This test check that we recogniez all the well known config names |
| 2 | +// and that we correctly lint on unexpected values. |
| 3 | +// |
| 4 | +// This test also serve as an "anti-regression" for the well known |
| 5 | +// values since the suggestion shows them. |
3 | 6 | // |
4 | 7 | // check-pass |
5 | 8 | // compile-flags: --check-cfg=cfg() -Z unstable-options |
6 | 9 |
|
| 10 | +#![feature(cfg_overflow_checks)] |
| 11 | +#![feature(cfg_target_has_atomic)] |
| 12 | +#![feature(cfg_target_has_atomic_equal_alignment)] |
| 13 | +#![feature(cfg_target_abi)] |
| 14 | +#![feature(cfg_relocation_model)] |
| 15 | +#![feature(cfg_sanitize)] |
| 16 | +#![feature(cfg_target_thread_local)] |
| 17 | + |
| 18 | +#[cfg(any( |
| 19 | + doc = "_UNEXPECTED_VALUE", |
| 20 | + //~^ WARN unexpected `cfg` condition value |
| 21 | + miri = "_UNEXPECTED_VALUE", |
| 22 | + //~^ WARN unexpected `cfg` condition value |
| 23 | + unix = "_UNEXPECTED_VALUE", |
| 24 | + //~^ WARN unexpected `cfg` condition value |
| 25 | + test = "_UNEXPECTED_VALUE", |
| 26 | + //~^ WARN unexpected `cfg` condition value |
| 27 | + doctest = "_UNEXPECTED_VALUE", |
| 28 | + //~^ WARN unexpected `cfg` condition value |
| 29 | + windows = "_UNEXPECTED_VALUE", |
| 30 | + //~^ WARN unexpected `cfg` condition value |
| 31 | + proc_macro = "_UNEXPECTED_VALUE", |
| 32 | + //~^ WARN unexpected `cfg` condition value |
| 33 | + panic = "_UNEXPECTED_VALUE", |
| 34 | + //~^ WARN unexpected `cfg` condition value |
| 35 | + sanitize = "_UNEXPECTED_VALUE", |
| 36 | + //~^ WARN unexpected `cfg` condition value |
| 37 | + relocation_model = "_UNEXPECTED_VALUE", |
| 38 | + //~^ WARN unexpected `cfg` condition value |
| 39 | + debug_assertions = "_UNEXPECTED_VALUE", |
| 40 | + //~^ WARN unexpected `cfg` condition value |
| 41 | + overflow_checks = "_UNEXPECTED_VALUE", |
| 42 | + //~^ WARN unexpected `cfg` condition value |
| 43 | + target_thread_local = "_UNEXPECTED_VALUE", |
| 44 | + //~^ WARN unexpected `cfg` condition value |
| 45 | + target_feature = "_UNEXPECTED_VALUE", // currently no values are checked |
| 46 | + target_os = "_UNEXPECTED_VALUE", |
| 47 | + //~^ WARN unexpected `cfg` condition value |
| 48 | + target_family = "_UNEXPECTED_VALUE", |
| 49 | + //~^ WARN unexpected `cfg` condition value |
| 50 | + target_arch = "_UNEXPECTED_VALUE", |
| 51 | + //~^ WARN unexpected `cfg` condition value |
| 52 | + target_endian = "_UNEXPECTED_VALUE", |
| 53 | + //~^ WARN unexpected `cfg` condition value |
| 54 | + target_env = "_UNEXPECTED_VALUE", |
| 55 | + //~^ WARN unexpected `cfg` condition value |
| 56 | + target_abi = "_UNEXPECTED_VALUE", |
| 57 | + //~^ WARN unexpected `cfg` condition value |
| 58 | + target_vendor = "_UNEXPECTED_VALUE", |
| 59 | + //~^ WARN unexpected `cfg` condition value |
| 60 | + target_pointer_width = "_UNEXPECTED_VALUE", |
| 61 | + //~^ WARN unexpected `cfg` condition value |
| 62 | + target_has_atomic = "_UNEXPECTED_VALUE", |
| 63 | + //~^ WARN unexpected `cfg` condition value |
| 64 | + target_has_atomic_load_store = "_UNEXPECTED_VALUE", |
| 65 | + //~^ WARN unexpected `cfg` condition value |
| 66 | + target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE" |
| 67 | + //~^ WARN unexpected `cfg` condition value |
| 68 | +))] |
| 69 | +fn unexpected_values() {} |
| 70 | + |
| 71 | +// testing that we suggest `linux` |
7 | 72 | #[cfg(target_os = "linuz")] |
8 | 73 | //~^ WARNING unexpected `cfg` condition value |
9 | 74 | fn target_os_linux_misspell() {} |
10 | 75 |
|
11 | 76 | #[cfg(target_os = "linux")] |
12 | 77 | fn target_os_linux() {} |
13 | 78 |
|
14 | | -#[cfg(target_has_atomic = "0")] |
15 | | -//~^ WARNING unexpected `cfg` condition value |
16 | | -fn target_has_atomic_invalid() {} |
17 | | - |
18 | 79 | #[cfg(target_has_atomic = "8")] |
19 | 80 | fn target_has_atomic() {} |
20 | 81 |
|
21 | | -#[cfg(unix = "aa")] |
22 | | -//~^ WARNING unexpected `cfg` condition value |
23 | | -fn unix_with_value() {} |
24 | | - |
25 | 82 | #[cfg(unix)] |
26 | 83 | fn unix() {} |
27 | 84 |
|
28 | | -#[cfg(miri = "miri")] |
29 | | -//~^ WARNING unexpected `cfg` condition value |
30 | | -fn miri_with_value() {} |
31 | | - |
32 | 85 | #[cfg(miri)] |
33 | 86 | fn miri() {} |
34 | 87 |
|
35 | | -#[cfg(doc = "linux")] |
36 | | -//~^ WARNING unexpected `cfg` condition value |
37 | | -fn doc_with_value() {} |
38 | | - |
39 | 88 | #[cfg(doc)] |
40 | 89 | fn doc() {} |
41 | 90 |
|
|
0 commit comments