forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#118213 - Urgau:check-cfg-diagnostics-rustc-ca…
…rgo, r=petrochenkov Add more suggestions to unexpected cfg names and values This pull request adds more suggestion to unexpected cfg names and values diagnostics: - it first adds a links to the [rustc unstable book](https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html) or the [Cargo reference](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg), depending if rustc is invoked by Cargo - it secondly adds a suggestion on how to expect the cfg name or value: *excluding well known names and values* - for Cargo: it suggest using a feature or `cargo:rust-check-cfg` in build script - for rustc: it suggest using `--check-cfg` (with the correct invocation) Those diagnostics improvements are directed towards enabling users to fix the issue if the previous suggestions weren't good enough. r? `@petrochenkov`
- Loading branch information
Showing
36 changed files
with
468 additions
and
326 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
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,31 @@ | ||
warning: unexpected `cfg` condition name: `feature` | ||
--> $DIR/cargo-feature.rs:13:7 | ||
| | ||
LL | #[cfg(feature = "serde")] | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider defining some features in `Cargo.toml` | ||
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration | ||
= note: `#[warn(unexpected_cfgs)]` on by default | ||
|
||
warning: unexpected `cfg` condition name: `tokio_unstable` | ||
--> $DIR/cargo-feature.rs:18:7 | ||
| | ||
LL | #[cfg(tokio_unstable)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `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`, `unix`, `windows` | ||
= help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(tokio_unstable)");` to the top of a `build.rs` | ||
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration | ||
|
||
warning: unexpected `cfg` condition name: `CONFIG_NVME` | ||
--> $DIR/cargo-feature.rs:22:7 | ||
| | ||
LL | #[cfg(CONFIG_NVME = "m")] | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(CONFIG_NVME, values(\"m\"))");` to the top of a `build.rs` | ||
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration | ||
|
||
warning: 3 warnings emitted | ||
|
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,35 @@ | ||
warning: unexpected `cfg` condition value: `serde` | ||
--> $DIR/cargo-feature.rs:13:7 | ||
| | ||
LL | #[cfg(feature = "serde")] | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: expected values for `feature` are: `bitcode` | ||
= help: consider adding `serde` as a feature in `Cargo.toml` | ||
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration | ||
= note: `#[warn(unexpected_cfgs)]` on by default | ||
|
||
warning: unexpected `cfg` condition name: `tokio_unstable` | ||
--> $DIR/cargo-feature.rs:18:7 | ||
| | ||
LL | #[cfg(tokio_unstable)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= help: expected names are: `CONFIG_NVME`, `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `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`, `unix`, `windows` | ||
= help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(tokio_unstable)");` to the top of a `build.rs` | ||
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration | ||
|
||
warning: unexpected `cfg` condition value: `m` | ||
--> $DIR/cargo-feature.rs:22:7 | ||
| | ||
LL | #[cfg(CONFIG_NVME = "m")] | ||
| ^^^^^^^^^^^^^^--- | ||
| | | ||
| help: there is a expected value with a similar name: `"y"` | ||
| | ||
= note: expected values for `CONFIG_NVME` are: `y` | ||
= help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(CONFIG_NVME, values(\"m\"))");` to the top of a `build.rs` | ||
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration | ||
|
||
warning: 3 warnings emitted | ||
|
This file was deleted.
Oops, something went wrong.
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,71 @@ | ||
warning: unexpected `cfg` condition name: `featur` | ||
--> $DIR/diagnotics.rs:7:7 | ||
| | ||
LL | #[cfg(featur)] | ||
| ^^^^^^ help: there is a config with a similar name: `feature` | ||
| | ||
= help: expected values for `feature` are: `foo` | ||
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration | ||
= note: `#[warn(unexpected_cfgs)]` on by default | ||
|
||
warning: unexpected `cfg` condition name: `featur` | ||
--> $DIR/diagnotics.rs:11:7 | ||
| | ||
LL | #[cfg(featur = "foo")] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration | ||
help: there is a config with a similar name and value | ||
| | ||
LL | #[cfg(feature = "foo")] | ||
| ~~~~~~~ | ||
|
||
warning: unexpected `cfg` condition name: `featur` | ||
--> $DIR/diagnotics.rs:15:7 | ||
| | ||
LL | #[cfg(featur = "fo")] | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= help: expected values for `feature` are: `foo` | ||
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration | ||
help: there is a config with a similar name and different values | ||
| | ||
LL | #[cfg(feature = "foo")] | ||
| ~~~~~~~~~~~~~~~ | ||
|
||
warning: unexpected `cfg` condition name: `no_value` | ||
--> $DIR/diagnotics.rs:22:7 | ||
| | ||
LL | #[cfg(no_value)] | ||
| ^^^^^^^^ help: there is a config with a similar name: `no_values` | ||
| | ||
= help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(no_value)");` to the top of a `build.rs` | ||
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration | ||
|
||
warning: unexpected `cfg` condition name: `no_value` | ||
--> $DIR/diagnotics.rs:26:7 | ||
| | ||
LL | #[cfg(no_value = "foo")] | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(no_value, values(\"foo\"))");` to the top of a `build.rs` | ||
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration | ||
help: there is a config with a similar name and no value | ||
| | ||
LL | #[cfg(no_values)] | ||
| ~~~~~~~~~ | ||
|
||
warning: unexpected `cfg` condition value: `bar` | ||
--> $DIR/diagnotics.rs:30:7 | ||
| | ||
LL | #[cfg(no_values = "bar")] | ||
| ^^^^^^^^^-------- | ||
| | | ||
| help: remove the value | ||
| | ||
= note: no expected value for `no_values` | ||
= help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(no_values, values(\"bar\"))");` to the top of a `build.rs` | ||
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration | ||
|
||
warning: 6 warnings emitted | ||
|
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
Oops, something went wrong.