-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fix invalid check-cfg Cargo feature diagnostic help #119425
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
@@ -804,8 +804,6 @@ pub trait LintContext { | |||
db.span_suggestion(value_span, "there is a expected value with a similar name", format!("\"{best_match}\""), Applicability::MaybeIncorrect); | |||
|
|||
} | |||
} else if name == sym::feature && is_from_cargo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated comment, but I feel like all of this logic should be moved to a separate module instead of being in this big match
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've put up #119443 to address this suggestion
r=me when CI is happy |
✌️ @Urgau, you can now approve this pull request! If @Nilstrieb told you to " |
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#119158 (Clean up alloc::sync::Weak Clone implementation) - rust-lang#119386 (fix typo in `IpAddr::to_canonical`) - rust-lang#119413 (solaris support on bootstrap lock) - rust-lang#119424 (Primitive docs: fix confusing `Send` in `&T`'s list) - rust-lang#119425 (Fix invalid check-cfg Cargo feature diagnostic help) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#119425 - Urgau:check-cfg-fix-cargo-diag-bug, r=Nilstrieb Fix invalid check-cfg Cargo feature diagnostic help rust-lang#118213 added specialized diagnostic for Cargo `feature` cfg. However when providing an empty `#[cfg(feature)]` condition the suggestion would suggest adding `feature` as a feature in `Cargo.toml` (wtf!). This PR removes the invalid logic, which even brings a nice improvement. ```diff --> $DIR/cargo-feature.rs:18:7 | LL | #[cfg(feature)] - | ^^^^^^^ + | ^^^^^^^- help: specify a config value: `= "bitcode"` | = note: expected values for `feature` are: `bitcode` - = help: consider defining `feature` as feature in `Cargo.toml` ``` The first commit add a test showing the bug and the second commit fixes the bug. `@rustbot` label +F-check-cfg
…xt, r=Nilstrieb Move around the code responsible for decorating builtin diagnostics This PR move the code responsible for decorating builtin diagnostics into a separate sub-module for ease of use and readability. While my original intention was to also move the check-cfg unexpected logic in their own function I changed my mind after moving the match altogether. I can move those if desired. Fixes rust-lang#119425 (comment) r? `@Nilstrieb`
…xt, r=Nilstrieb Move around the code responsible for decorating builtin diagnostics This PR move the code responsible for decorating builtin diagnostics into a separate sub-module for ease of use and readability. While my original intention was to also move the check-cfg unexpected logic in their own function I changed my mind after moving the match altogether. I can move those if desired. Fixes rust-lang#119425 (comment) r? `@Nilstrieb`
#118213 added specialized diagnostic for Cargo
feature
cfg. However when providing an empty#[cfg(feature)]
condition the suggestion would suggest addingfeature
as a feature inCargo.toml
(wtf!).This PR removes the invalid logic, which even brings a nice improvement.
The first commit add a test showing the bug and the second commit fixes the bug.
@rustbot label +F-check-cfg