Skip to content

Unexpected cfgs warns on quite-intentional user-cfgs #124821

Closed as not planned
Closed as not planned
@workingjubilee

Description

@workingjubilee

Cargo features are not actually appropriate for all conditional compilation, as not all conditional-compilation-keys are additive. Some are in fact mutually exclusive. Cargo does not have an adequate answer for this problem yet. It is my opinion that in general, except when it is likely a typo (levenshtein 1 from an expected cfg key or key-value pair) or is an unknown value for an expected cfg key, the Rust compiler should not be quite as judgemental of "interesting" uses of cfgs.

Because rustc complained about so many cfgs, this basically clobbered backtrace-rs with a million irrelevant warnings that almost drowned out the one or two interesting things that did need to be fixed.

There are also ecosystem crates that use the pattern of requiring users to set a cfg to enable something, to yield control to the binary's builder, despite being a library crate, or that use it for things that should not be resolved the same way Cargo features are.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.F-check-cfg--check-cfgT-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