-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve well known value check-cfg diagnostic for the standard library #127221
Merged
Conversation
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
rustbot
added
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Jul 1, 2024
@bors r+ rollup |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Jul 5, 2024
workingjubilee
added a commit
to workingjubilee/rustc
that referenced
this pull request
Jul 5, 2024
Improve well known value check-cfg diagnostic for the standard library This PR adjust the current logic for hidding the rustc/Cargo suggestion to add a value to a well-known name to exclude the standard library and rustc crates. This is done in order to improve the contributor experience, in particular when adding a new target, which often requires adding some cfgs like `target_os` which may not be available yet in stage0. <details> The diagnostic code would look like this. ```text error: unexpected `cfg` condition value: `blable` --> library/core/src/lib.rs:369:7 | 369 | #[cfg(target_os = "blable")] | ^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, and `windows` and 2 more = 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(target_os, values("blable"))'] } = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(target_os, values(\"blable\"))");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration = note: `-D unexpected-cfgs` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unexpected_cfgs)]` ``` </details>
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 5, 2024
…kingjubilee Rollup of 11 pull requests Successful merges: - rust-lang#123600 (impl PathBuf::add_extension and Path::with_added_extension) - rust-lang#126987 (out_of_scope_macro_calls: Detect calls inside attributes more precisely) - rust-lang#127107 (Improve dead code analysis) - rust-lang#127221 (Improve well known value check-cfg diagnostic for the standard library) - rust-lang#127333 (Split `SolverDelegate` back out from `InferCtxtLike`) - rust-lang#127363 (Improve readability of some fmt code examples) - rust-lang#127366 (Use `ControlFlow` results for visitors that are only looking for a single value) - rust-lang#127368 (Added dots at the sentence ends of rustc AST doc) - rust-lang#127369 (Match ergonomics 2024: align with RFC again) - rust-lang#127383 (Use verbose style for argument removal suggestion) - rust-lang#127393 (Remove clubby789 from review rotation) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 6, 2024
…mpiler-errors Rollup of 8 pull requests Successful merges: - rust-lang#123600 (impl PathBuf::add_extension and Path::with_added_extension) - rust-lang#127107 (Improve dead code analysis) - rust-lang#127221 (Improve well known value check-cfg diagnostic for the standard library) - rust-lang#127333 (Split `SolverDelegate` back out from `InferCtxtLike`) - rust-lang#127363 (Improve readability of some fmt code examples) - rust-lang#127366 (Use `ControlFlow` results for visitors that are only looking for a single value) - rust-lang#127368 (Added dots at the sentence ends of rustc AST doc) - rust-lang#127393 (Remove clubby789 from review rotation) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 6, 2024
Rollup merge of rust-lang#127221 - Urgau:check-cfg-std-diag, r=pnkfelix Improve well known value check-cfg diagnostic for the standard library This PR adjust the current logic for hidding the rustc/Cargo suggestion to add a value to a well-known name to exclude the standard library and rustc crates. This is done in order to improve the contributor experience, in particular when adding a new target, which often requires adding some cfgs like `target_os` which may not be available yet in stage0. <details> The diagnostic code would look like this. ```text error: unexpected `cfg` condition value: `blable` --> library/core/src/lib.rs:369:7 | 369 | #[cfg(target_os = "blable")] | ^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, and `windows` and 2 more = 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(target_os, values("blable"))'] } = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(target_os, values(\"blable\"))");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration = note: `-D unexpected-cfgs` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unexpected_cfgs)]` ``` </details>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adjust the current logic for hidding the rustc/Cargo suggestion to add a value to a well-known name to exclude the standard library and rustc crates.
This is done in order to improve the contributor experience, in particular when adding a new target, which often requires adding some cfgs like
target_os
which may not be available yet in stage0.The diagnostic code would look like this.