2023-12-07 05:04:00 -06:00
|
|
|
// This test check that we recognize all the well known config names
|
|
|
|
// and that we correctly lint on unexpected values.
|
|
|
|
//
|
|
|
|
// This test also serve as an "anti-regression" for the well known
|
|
|
|
// values since the suggestion shows them.
|
2022-02-25 09:10:26 -06:00
|
|
|
//
|
|
|
|
// check-pass
|
2023-05-01 07:16:38 -05:00
|
|
|
// compile-flags: --check-cfg=cfg() -Z unstable-options
|
2022-02-25 09:10:26 -06:00
|
|
|
|
2023-12-07 05:04:00 -06:00
|
|
|
#![feature(cfg_overflow_checks)]
|
|
|
|
#![feature(cfg_relocation_model)]
|
|
|
|
#![feature(cfg_sanitize)]
|
|
|
|
#![feature(cfg_target_abi)]
|
|
|
|
#![feature(cfg_target_has_atomic)]
|
|
|
|
#![feature(cfg_target_has_atomic_equal_alignment)]
|
|
|
|
#![feature(cfg_target_thread_local)]
|
|
|
|
|
|
|
|
// This part makes sure that none of the well known names are
|
|
|
|
// unexpected.
|
|
|
|
//
|
|
|
|
// BUT to make sure that no expected values changes without
|
|
|
|
// being noticed we pass them a obviously wrong value so the
|
|
|
|
// diagnostic prints the list of expected values.
|
|
|
|
#[cfg(any(
|
|
|
|
// tidy-alphabetical-start
|
|
|
|
debug_assertions = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
doc = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
doctest = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
miri = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
overflow_checks = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
panic = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
proc_macro = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
relocation_model = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
sanitize = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
target_abi = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
target_arch = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
target_endian = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
target_env = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
target_family = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
2023-12-12 15:04:48 -06:00
|
|
|
target_feature = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
2023-12-07 05:04:00 -06:00
|
|
|
target_has_atomic = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
target_has_atomic_load_store = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
target_os = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
target_pointer_width = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
target_thread_local = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
target_vendor = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
test = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
unix = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
windows = "_UNEXPECTED_VALUE",
|
|
|
|
//~^ WARN unexpected `cfg` condition value
|
|
|
|
// tidy-alphabetical-end
|
|
|
|
))]
|
|
|
|
fn unexpected_values() {}
|
|
|
|
|
|
|
|
#[cfg(target_os = "linuz")] // testing that we suggest `linux`
|
2022-02-25 09:10:26 -06:00
|
|
|
//~^ WARNING unexpected `cfg` condition value
|
|
|
|
fn target_os_linux_misspell() {}
|
|
|
|
|
2023-12-07 05:04:00 -06:00
|
|
|
// The #[cfg]s below serve as a safeguard to make sure we
|
|
|
|
// don't lint when using an expected well-known name and
|
|
|
|
// value, only a small subset of all possible expected
|
|
|
|
// configs are tested, since we already test the names
|
|
|
|
// above and don't need to test all values, just different
|
|
|
|
// combinations (without value, with value, both...).
|
|
|
|
|
2022-02-25 09:10:26 -06:00
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
fn target_os_linux() {}
|
|
|
|
|
2023-12-12 15:17:41 -06:00
|
|
|
#[cfg(target_feature = "crt-static")] // pure rustc feature
|
|
|
|
fn target_feature() {}
|
|
|
|
|
2022-02-25 09:10:26 -06:00
|
|
|
#[cfg(target_has_atomic = "8")]
|
2023-12-07 05:04:00 -06:00
|
|
|
fn target_has_atomic_8() {}
|
2022-02-25 09:10:26 -06:00
|
|
|
|
2023-12-07 05:04:00 -06:00
|
|
|
#[cfg(target_has_atomic)]
|
|
|
|
fn target_has_atomic() {}
|
2022-02-25 09:10:26 -06:00
|
|
|
|
|
|
|
#[cfg(unix)]
|
|
|
|
fn unix() {}
|
|
|
|
|
2022-03-09 09:52:38 -06:00
|
|
|
#[cfg(doc)]
|
|
|
|
fn doc() {}
|
|
|
|
|
2022-02-25 09:10:26 -06:00
|
|
|
fn main() {}
|