Skip to content
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

Suggest name value cfg when only value is used for check-cfg #120427

Closed
Noratrieb opened this issue Jan 27, 2024 · 0 comments · Fixed by #120435
Closed

Suggest name value cfg when only value is used for check-cfg #120427

Noratrieb opened this issue Jan 27, 2024 · 0 comments · Fixed by #120435
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. F-check-cfg --check-cfg T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Noratrieb
Copy link
Member

Code

#[cfg(linux)]
fn x() {}

fn main() {}

Current output

warning: unexpected `cfg` condition name: `linux`
 --> t.rs:1:7
  |
1 | #[cfg(linux)]
  |       ^^^^^
  |
  = 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: to expect this configuration use `--check-cfg=cfg(linux)`
  = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration
  = note: `#[warn(unexpected_cfgs)]` on by default

Desired output

= help: try `cfg(target_os = "linux")`

Rationale and extra context

The user wanted something with "linux", and there is a name-value cfg that has the value "linux", so they probably wanted that.

Other cases

many other possible name-value cfgs...

Rust Version

rustc 1.77.0-nightly (5bd5d214e 2024-01-25)

Anything else?

No response

@Noratrieb Noratrieb added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. F-check-cfg --check-cfg labels Jan 27, 2024
@chenyukang chenyukang self-assigned this Jan 28, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 30, 2024
…ame, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? `@Nilstrieb`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 30, 2024
…ame, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? ``@Nilstrieb``
Nadrieril added a commit to Nadrieril/rust that referenced this issue Jan 31, 2024
…ame, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? ```@Nilstrieb```
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 3, 2024
…ame, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? ````@Nilstrieb````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 3, 2024
…ame, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? `````@Nilstrieb`````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 5, 2024
…ame, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? ``````@Nilstrieb``````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 5, 2024
…ame, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? ```````@Nilstrieb```````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 5, 2024
…ame, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? ````````@Nilstrieb````````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 5, 2024
…ame, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? `````````@Nilstrieb`````````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 5, 2024
…ame, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? ``````````@Nilstrieb``````````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 6, 2024
…ame, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? ```````````@Nilstrieb```````````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 6, 2024
…ame, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? ````````````@Nilstrieb````````````
@bors bors closed this as completed in 0a4702d Feb 7, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 7, 2024
Rollup merge of rust-lang#120435 - chenyukang:yukang-fix-120427-cfg-name, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? `````````````@Nilstrieb`````````````
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. F-check-cfg --check-cfg T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants