-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make --check-cfg use a different lint for CLI --cfg checking
- Loading branch information
Showing
5 changed files
with
99 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Check for unexpected configuration value in the code. | ||
// | ||
// check-pass | ||
// compile-flags: -Z unstable-options | ||
// compile-flags: --cfg foo --cfg bar --cfg feature="bar" | ||
// compile-flags: --check-cfg=cfg(feature,values("serde","full")) | ||
// | ||
// error-pattern: unexpected `foo` as condition name | ||
// error-pattern: unexpected `bar` as condition name | ||
// error-pattern: unexpected condition value `bar` for condition name `feature` | ||
// error-pattern: was set with `--cfg` but isn't in the `--check-cfg` expected | ||
|
||
#![warn(unexpected_cli_cfgs)] | ||
|
||
#[cfg(feature = "bar")] | ||
//~^ WARNING unexpected `cfg` condition value | ||
pub fn f() {} | ||
|
||
#[cfg(foo)] | ||
//~^ WARNING unexpected `cfg` condition name | ||
pub fn foo() {} | ||
|
||
pub fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
warning: unexpected `cfg` condition value: `bar` | ||
--> $DIR/unexpected-cli-cfg.rs:15:7 | ||
| | ||
LL | #[cfg(feature = "bar")] | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
= note: expected values for `feature` are: `full`, `serde` | ||
= note: `#[warn(unexpected_cfgs)]` on by default | ||
|
||
warning: unexpected `cfg` condition name: `foo` | ||
--> $DIR/unexpected-cli-cfg.rs:19:7 | ||
| | ||
LL | #[cfg(foo)] | ||
| ^^^ | ||
| | ||
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` | ||
|
||
warning: unexpected `foo` as condition name | ||
| | ||
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names | ||
note: the lint level is defined here | ||
--> $DIR/unexpected-cli-cfg.rs:13:9 | ||
| | ||
LL | #![warn(unexpected_cli_cfgs)] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
||
warning: unexpected `bar` as condition name | ||
| | ||
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names | ||
|
||
warning: unexpected condition value `bar` for condition name `feature` | ||
| | ||
= help: was set with `--cfg` but isn't in the `--check-cfg` expected values | ||
|
||
warning: 5 warnings emitted | ||
|