Add warning against unexpected --cfg with --check-cfg
This commit is contained in:
parent
137eea86db
commit
eccdccf4eb
8 changed files with 66 additions and 4 deletions
8
src/test/ui/check-cfg/allow-at-crate-level.rs
Normal file
8
src/test/ui/check-cfg/allow-at-crate-level.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// This test check that #![allow(unexpected_cfgs)] works with --cfg
|
||||
//
|
||||
// check-pass
|
||||
// compile-flags: --cfg=unexpected --check-cfg=names() -Z unstable-options
|
||||
|
||||
#![allow(unexpected_cfgs)]
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -15,5 +15,9 @@ LL | #[cfg(feature = "rand")]
|
|||
|
|
||||
= note: expected values for `feature` are: full, serde
|
||||
|
||||
warning: 2 warnings emitted
|
||||
warning: unexpected condition value `rand` for condition name `feature`
|
||||
|
|
||||
= help: was set with `--cfg` but isn't in the `--check-cfg` expected values
|
||||
|
||||
warning: 3 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// we correctly lint on the `cfg!` macro and `cfg_attr` attribute.
|
||||
//
|
||||
// check-pass
|
||||
// compile-flags: --check-cfg=names() --check-cfg=values(feature,"foo") --cfg feature="bar" -Z unstable-options
|
||||
// compile-flags: --check-cfg=names() --check-cfg=values(feature,"foo") --cfg feature="bar" --cfg unknown_name -Z unstable-options
|
||||
|
||||
#[cfg(windows)]
|
||||
fn do_windows_stuff() {}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,14 @@ warning: unexpected `cfg` condition name
|
|||
LL | #[cfg_attr(uu, test)]
|
||||
| ^^
|
||||
|
||||
warning: unexpected condition value `bar` for condition name `feature`
|
||||
|
|
||||
= help: was set with `--cfg` but isn't in the `--check-cfg` expected values
|
||||
|
||||
warning: unexpected `unknown_name` as condition name
|
||||
|
|
||||
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names
|
||||
|
||||
warning: unexpected `cfg` condition name
|
||||
--> $DIR/mix.rs:35:10
|
||||
|
|
||||
|
|
@ -170,5 +178,5 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
|
|||
|
|
||||
= note: expected values for `feature` are: foo
|
||||
|
||||
warning: 25 warnings emitted
|
||||
warning: 27 warnings emitted
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue