Lints for target_* cfg #85753
Labels
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Inspired by seeing #85738 fixing a typo by replacing
target_os = "opensbd"
withtarget_os = "openbsd"
.I wonder whether cases like this could be discovered by lints. There are multiple
target_*
values that rustc sets, and it would be interesting to think about validating them.Rust has support for custom target json files, and ideally you would want to have older rustc versions not warn about code supporting targets added by future rustc versoins, making a warn-by-default lint that complains about any non-builtin
target_*
value a bit tricky.However, one could think about an allow-by-default
non_builtin_target_cfg
lint, as well as a warn-by-defaulttarget_cfg_typo
lint that checks for targets in a close edit distance to a builtin target. If you enable thenon_builtin_target_cfg
lint, maybe thetarget_cfg_typo
could be silenced.As prior art I was only able to find a clippy lint.
The text was updated successfully, but these errors were encountered: