2023-11-16 11:41:45 -06:00
|
|
|
// This test checks the combination of well known names, the usage of cfg(),
|
|
|
|
// and that no implicit cfgs is added from --cfg while also testing that
|
2022-07-20 10:31:15 -05:00
|
|
|
// we correctly lint on the `cfg!` macro and `cfg_attr` attribute.
|
2022-02-19 18:26:52 -06:00
|
|
|
//
|
|
|
|
//@ check-pass
|
2023-05-01 07:16:38 -05:00
|
|
|
//@ compile-flags: --cfg feature="bar" --cfg unknown_name -Z unstable-options
|
2023-11-16 11:41:45 -06:00
|
|
|
//@ compile-flags: --check-cfg=cfg(feature,values("foo"))
|
2022-02-19 18:26:52 -06:00
|
|
|
|
|
|
|
#[cfg(windows)]
|
|
|
|
fn do_windows_stuff() {}
|
|
|
|
|
|
|
|
#[cfg(widnows)]
|
|
|
|
//~^ WARNING unexpected `cfg` condition name
|
|
|
|
fn do_windows_stuff() {}
|
|
|
|
|
2023-04-30 12:09:15 -05:00
|
|
|
#[cfg(feature)]
|
|
|
|
//~^ WARNING unexpected `cfg` condition value
|
|
|
|
fn no_feature() {}
|
|
|
|
|
2022-02-19 18:26:52 -06:00
|
|
|
#[cfg(feature = "foo")]
|
|
|
|
fn use_foo() {}
|
|
|
|
|
|
|
|
#[cfg(feature = "bar")]
|
2022-07-20 10:31:15 -05:00
|
|
|
//~^ WARNING unexpected `cfg` condition value
|
2022-02-19 18:26:52 -06:00
|
|
|
fn use_bar() {}
|
|
|
|
|
|
|
|
#[cfg(feature = "zebra")]
|
|
|
|
//~^ WARNING unexpected `cfg` condition value
|
|
|
|
fn use_zebra() {}
|
|
|
|
|
|
|
|
#[cfg_attr(uu, test)]
|
|
|
|
//~^ WARNING unexpected `cfg` condition name
|
|
|
|
fn do_test() {}
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "foo", no_mangle)]
|
|
|
|
fn do_test_foo() {}
|
|
|
|
|
|
|
|
fn test_cfg_macro() {
|
|
|
|
cfg!(windows);
|
|
|
|
cfg!(widnows);
|
|
|
|
//~^ WARNING unexpected `cfg` condition name
|
|
|
|
cfg!(feature = "foo");
|
|
|
|
cfg!(feature = "bar");
|
2022-07-20 10:31:15 -05:00
|
|
|
//~^ WARNING unexpected `cfg` condition value
|
2022-02-19 18:26:52 -06:00
|
|
|
cfg!(feature = "zebra");
|
|
|
|
//~^ WARNING unexpected `cfg` condition value
|
|
|
|
cfg!(xxx = "foo");
|
|
|
|
//~^ WARNING unexpected `cfg` condition name
|
|
|
|
cfg!(xxx);
|
|
|
|
//~^ WARNING unexpected `cfg` condition name
|
|
|
|
cfg!(any(xxx, windows));
|
|
|
|
//~^ WARNING unexpected `cfg` condition name
|
|
|
|
cfg!(any(feature = "bad", windows));
|
|
|
|
//~^ WARNING unexpected `cfg` condition value
|
2022-03-19 04:23:09 -05:00
|
|
|
cfg!(any(windows, xxx));
|
|
|
|
//~^ WARNING unexpected `cfg` condition name
|
|
|
|
cfg!(all(unix, xxx));
|
|
|
|
//~^ WARNING unexpected `cfg` condition name
|
|
|
|
cfg!(all(aa, bb));
|
|
|
|
//~^ WARNING unexpected `cfg` condition name
|
|
|
|
//~| WARNING unexpected `cfg` condition name
|
|
|
|
cfg!(any(aa, bb));
|
|
|
|
//~^ WARNING unexpected `cfg` condition name
|
|
|
|
//~| WARNING unexpected `cfg` condition name
|
|
|
|
cfg!(any(unix, feature = "zebra"));
|
|
|
|
//~^ WARNING unexpected `cfg` condition value
|
|
|
|
cfg!(any(xxx, feature = "zebra"));
|
|
|
|
//~^ WARNING unexpected `cfg` condition name
|
|
|
|
//~| WARNING unexpected `cfg` condition value
|
|
|
|
cfg!(any(xxx, unix, xxx));
|
|
|
|
//~^ WARNING unexpected `cfg` condition name
|
|
|
|
//~| WARNING unexpected `cfg` condition name
|
|
|
|
cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
|
|
|
|
//~^ WARNING unexpected `cfg` condition value
|
|
|
|
//~| WARNING unexpected `cfg` condition value
|
|
|
|
//~| WARNING unexpected `cfg` condition value
|
2024-02-16 14:32:53 -06:00
|
|
|
cfg!(target_feature = "zebra");
|
|
|
|
//~^ WARNING unexpected `cfg` condition value
|
2022-02-19 18:26:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|