-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Warn for cfg!(target_* = "whatever") usage in build scripts #125441
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-cargoRelevant to the cargo team, which will review and decide on the PR/issue.Relevant to the cargo team, which will review and decide on the PR/issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-cargoRelevant to the cargo team, which will review and decide on the PR/issue.Relevant to the cargo team, which will review and decide on the PR/issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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::envin 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