Why do all feature flags appear enabled in one file?
⚓ Rust 📅 2025-08-27 👤 surdeus 👁️ 12Hi all,
I’ve run into something puzzling and was hoping someone might point me in the right direction. I’m working in a large codebase, and while investigating a performance issue I noticed that in one particular file all feature flags appear to be enabled (this makes a certain function execute multiple versions of itself instead of just one).
Here’s the confusing part:
- If I add something like
#[cfg(feature = "bob")]in other nearby files (and add the flag toCargo.toml), VS Code correctly shows it as disabled when the feature isn’t set. - But in this one file, any feature flag I try appears to be active, regardless of whether it’s actually enabled in
Cargo.toml. - I tried running
cargo clean, but the behavior didn’t change.
Does anyone know what might cause a single file to behave as if every feature flag is turned on? Where should I start looking? How should I debug this?
Thanks!
1 post - 1 participant
🏷️ Rust_feed