Add -Z check-cfg-features to enable compile-time checking of features by Urgau · Pull Request #10408 · rust-lang/cargo (original) (raw)

This pull-request implements the "Cargo support" section of RFC 3013: Checking conditional compilation at compile time.

The support is added in the form of an new unstable flags: -Z check-cfg-features that pass all possible features of a package to rustc unstable --check-cfg command line as --check-cfg=values(feature, ...). This enables compile time checking of feature values in #[cfg], cfg! and #[cfg_attr].

This new flag currently only affects rustc but rustdoc support will be added as soon as it's support is merged.

Note than the intent is that this command line options become the default when stabilizing as suggested in the RFC:

[..] it seems uncontroversial for Cargo to enable checking for feature = "..." values immediately [..]