diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-12-30 11:42:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-30 11:42:04 +0100 |
| commit | e930ea274e1b0cdc9f69b0e57f71c3893204aca6 (patch) | |
| tree | a90a15f8ca2d060bacdc2013775b32ada2582b0e /compiler/rustc_lint | |
| parent | 19580d56c2f9e014e95f9d7879fe207a034aad16 (diff) | |
| parent | a25e0236df95dae9c236b66391660d7910a16d5e (diff) | |
| download | rust-e930ea274e1b0cdc9f69b0e57f71c3893204aca6.tar.gz rust-e930ea274e1b0cdc9f69b0e57f71c3893204aca6.zip | |
Rollup merge of #119425 - Urgau:check-cfg-fix-cargo-diag-bug, r=Nilstrieb
Fix invalid check-cfg Cargo feature diagnostic help
#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
Diffstat (limited to 'compiler/rustc_lint')
| -rw-r--r-- | compiler/rustc_lint/src/context.rs | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 39c965e75d6..bd86a0be676 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -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 { - db.help(format!("consider defining `{name}` as feature in `Cargo.toml`")); } else if let &[first_possibility] = &possibilities[..] { db.span_suggestion(name_span.shrink_to_hi(), "specify a config value", format!(" = \"{first_possibility}\""), Applicability::MaybeIncorrect); } |
