-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
I'm creating a library crate with optional features and dependencies. In my Cargo.toml, I have:
[dependencies]
foo = { version = "0.4.14", optional = true }
[features]
bar_feature = ["dep:foo"]In lib.rs, I declared a module like this:
#[cfg(feature = "bar_feature")]
pub mod bar_backend;Then I created bar_backend/mod.rs. However, rust-analyzer isn't analyzing the file (not providing IDE services) because the module declaration is under a cfg attribute. The declaration appears greyed out with a message saying the code ignored feature is disabled
I understand that since the feature is disabled, the code is ignored, which prevents the module from being analyzed. I tried to enable the feature by:
- Creating a
rust-analyzer.jsonfile with:
{
"rust-analyzer.check.features": "all",
}This didn't work, and I couldn't verify if the rust-analyzer.json file was being read by rust-analyzer.
- Then I tried adding this to my
Cargo.toml:
[profile.dev]
features = ["bar_feature"]This un-greyed the module declaration (the #[cfg] part), but bar_backend/mod.rs is still not being analyzed.
Any way to get the IDE services in that file
I am working in neovim if you need other details ask