#[cfg(features = "something")]
compiles, creating a potential foot-gun
#108737
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-bug
Category: This is a bug.
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
I tried this code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=256c4dfff8b9a14d10ea75cb4e4aa2f5
I expected to see this happen:
A compiler error, or at least a suppressable warning specific to this situation. The valid syntax is
#[cfg(feature = ...]
, not#[cfg(features = ...]
, and as far as I know, there is no valid context where it would be#[cfg(features = [something]]
.Instead, this happened:
Right now this compiles without any errors or warnings. This caused a huge foot-gun for me in a project where I accidentally had
#[cfg(features = ...]
in several places and the compiler didn't fail or warn me in any way.Meta
rustc --version --verbose
:Note: this behavior is consistent in stable, beta, and nightly on the Rust Playground as of 03/04/2023.
The text was updated successfully, but these errors were encountered: