-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Mark existing well-known cfg as unknown #117778
Comments
This is an interesting idea and as currently noted there is no mechanism to mark an existing cfg as "unknown". I didn't knew one could set |
It can be useful to set There is also a Cargo issue somewhere about improving this output, but even without that, it would be nice if If |
Ah, I just checked rust-analyzer's behavior in detail and got reminded that println!("cargo:rustc-check-cfg=cfg(not(test))"); // or
println!("cargo:rustc-check-cfg-not=cfg(test)"); in |
I was more referring to the "usefulness" of the syntax where the only known user would have been Cargo As for the syntax it-self I could see us introducing something like
Hum. This reduce the usefulness to basically zero as marking |
Hm, maybe. I guess it depends on what the intention of edit: Have opened a forum post about this: https://users.rust-lang.org/t/cargo-what-is-the-purpose-of-lib-test-false/102361 |
### What does this PR try to resolve? This PR conditionally mark the `test` cfg as a well known cfg depending on the target unit "test" field (ie `lib.test = false`, `[[bin]] test = false` and others). This is related to rust-lang/rust#117778 and https://users.rust-lang.org/t/cargo-what-is-the-purpose-of-lib-test-false/102361. When defining `lib.test = false` (and others), any use of `cfg(test)` will trigger the `unexpected_cfgs` lint. ```toml [lib] test = false # will now warn on cfg(test) ``` ### How should we test and review this PR? Best reviewed commit by commit. Second commit removes the `test` cfg from the `--check-cfg` args. ### Additional information T-compiler [MCP#785](rust-lang/compiler-team#785) and #14963 were of preparatory work. r? @epage
Originally posted by @jplatte in #82450 (comment)
@rustbot label +C-discussion +F-check-cfg -needs-triage
The text was updated successfully, but these errors were encountered: