mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00

### 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 https://github.com/rust-lang/rust/issues/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](https://github.com/rust-lang/compiler-team/issues/785) and https://github.com/rust-lang/cargo/pull/14963 were of preparatory work. r? @epage