EXPLICIT_BUILTIN_CFGS_IN_FLAGS in rustc_lint_defs::builtin - Rust
Description: The `explicit_builtin_cfgs_in_flags` lint detects builtin cfgs set via the `--cfg` flag.

Skip to main content

## EXPLICIT_BUILTIN_CFGS_IN_FLAGS

# Static EXPLICIT_BUILTIN_CFGS_IN_FLAGS

Source

    pub static EXPLICIT_BUILTIN_CFGS_IN_FLAGS: &Lint

Expand description

The `explicit_builtin_cfgs_in_flags` lint detects builtin cfgs set via the `--cfg` flag.

#### §Example

    rustc --cfg unix

ⓘ

    fn main() {}

This will produce:

    error: unexpected `--cfg unix` flag
      |
      = note: config `unix` is only supposed to be controlled by `--target`
      = note: manually setting a built-in cfg can and does create incoherent behaviors
      = note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default

#### §Explanation

Setting builtin cfgs can and does produce incoherent behavior, it’s better to the use the appropriate `rustc` flag that controls the config. For example setting the `windows` cfg but on Linux based target.