Skip to content

Lints for target_* cfg #85753

Closed
Closed
@est31

Description

@est31

Inspired by seeing #85738 fixing a typo by replacing target_os = "opensbd" with target_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-default target_cfg_typo lint that checks for targets in a close edit distance to a builtin target. If you enable the non_builtin_target_cfg lint, maybe the target_cfg_typo could be silenced.

As prior art I was only able to find a clippy lint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions