Why do all feature flags appear enabled in one file?

Edit: Apologies, I think I misread some benchmarking numbers. I'm guessing it's a weird VS Code bug, not a Rust issue

Hi 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 to Cargo.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!

Is this file included in multiple crates?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.