IntelliJ plugin not disabling code behind #[cfg(feature = "...")]

I'm building a library, and I added some features to my Cargo.toml. Some features are off by default, but the editor in IntelliJ is showing them as enabled, with red-underlined errors in code that should be disabled. How do I control which features are on/off in the IDE's language analysis?

The editor is disabling things hidden behind other cfg attributes. For example, code after a #[cfg(target_os = "windows")] is grayed out on macOS.

[features]
vulkan = ["dep:ash", "dep:ash-window"]
wgpu = ["dep:wgpu"]
default = ["wgpu"]

But, code like this is not grayed out:

struct FontManager {
    #[cfg(feature = "vulkan")]
    device: Arc<Device>,

Building from command line with cargo build ... works fine.

Try opening you Cargo.toml. There should be checkboxes next to each feauture

2 Likes

It works. Thanks!