forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't suggest adding the unexpected cfgs the build-script it-self
- Loading branch information
Showing
4 changed files
with
107 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// This test checks that when we are building a build script provided | ||
// by Cargo we only suggest expecting the unexpected cfgs in the Cargo.toml. | ||
// | ||
//@ check-pass | ||
//@ no-auto-check-cfg | ||
//@ rustc-env:CARGO_CRATE_NAME=build_script_build | ||
//@ compile-flags:--crate-name=build_script_build | ||
//@ compile-flags:--check-cfg=cfg(has_bar) | ||
|
||
#[cfg(has_foo)] | ||
//~^ WARNING unexpected `cfg` condition name | ||
fn foo() {} | ||
|
||
#[cfg(has_foo = "yes")] | ||
//~^ WARNING unexpected `cfg` condition name | ||
fn foo() {} | ||
|
||
#[cfg(has_bar = "yes")] | ||
//~^ WARNING unexpected `cfg` condition value | ||
fn has_bar() {} | ||
|
||
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,43 @@ | ||
warning: unexpected `cfg` condition name: `has_foo` | ||
--> $DIR/cargo-build-script.rs:10:7 | ||
| | ||
LL | #[cfg(has_foo)] | ||
| ^^^^^^^ | ||
| | ||
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `has_bar`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `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`, `ub_checks`, `unix`, and `windows` | ||
= help: consider using a Cargo feature instead | ||
= help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: | ||
[lints.rust] | ||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(has_foo)'] } | ||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration | ||
= note: `#[warn(unexpected_cfgs)]` on by default | ||
|
||
warning: unexpected `cfg` condition name: `has_foo` | ||
--> $DIR/cargo-build-script.rs:14:7 | ||
| | ||
LL | #[cfg(has_foo = "yes")] | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider using a Cargo feature instead | ||
= help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: | ||
[lints.rust] | ||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(has_foo, values("yes"))'] } | ||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration | ||
|
||
warning: unexpected `cfg` condition value: `yes` | ||
--> $DIR/cargo-build-script.rs:18:7 | ||
| | ||
LL | #[cfg(has_bar = "yes")] | ||
| ^^^^^^^-------- | ||
| | | ||
| help: remove the value | ||
| | ||
= note: no expected value for `has_bar` | ||
= help: consider using a Cargo feature instead | ||
= help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: | ||
[lints.rust] | ||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(has_bar, values("yes"))'] } | ||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration | ||
|
||
warning: 3 warnings emitted | ||
|