Warn for cfg!(target_* = "whatever")
usage in build scripts
#125441
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-cargo
Relevant to the cargo team, which will review and decide on the PR/issue.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
I would expect a warning that explains that
cfg!(target_*)
will be evaluated in the context of the host system that compiles the build script and not in the context of the target system. It seems to be a common mistake for crate authors writing build scripts to usecfg!
and notstd::env
in combination with the environment variables set by cargo. The warning should suggest that the later variant is the correct solution there.Other cases
No response
Rust Version
Anything else?
No response
The text was updated successfully, but these errors were encountered: