Add test for well known names defined by rustc

This commit is contained in:
Loïc BRANSTETT 2022-02-20 00:04:10 +01:00
parent da896d35f4
commit fbe1c153ec
2 changed files with 49 additions and 0 deletions

View file

@ -0,0 +1,27 @@
// This test checks that we lint on non well known names and that we don't lint on well known names
//
// check-pass
// compile-flags: --check-cfg=names() -Z unstable-options
#[cfg(target_oz = "linux")]
//~^ WARNING unexpected `cfg` condition name
fn target_os_misspell() {}
#[cfg(target_os = "linux")]
fn target_os() {}
#[cfg(features = "foo")]
//~^ WARNING unexpected `cfg` condition name
fn feature_misspell() {}
#[cfg(feature = "foo")]
fn feature() {}
#[cfg(uniw)]
//~^ WARNING unexpected `cfg` condition name
fn unix_misspell() {}
#[cfg(unix)]
fn unix() {}
fn main() {}

View file

@ -0,0 +1,22 @@
warning: unexpected `cfg` condition name
--> $DIR/well-known-names.rs:6:7
|
LL | #[cfg(target_oz = "linux")]
| ^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition name
--> $DIR/well-known-names.rs:13:7
|
LL | #[cfg(features = "foo")]
| ^^^^^^^^^^^^^^^^
warning: unexpected `cfg` condition name
--> $DIR/well-known-names.rs:20:7
|
LL | #[cfg(uniw)]
| ^^^^
warning: 3 warnings emitted