How to work on optional feature library?

Hi Guys!

I have a library which have have optional features. Its important because there are feature related dependencies, that can expand the build size and time as well.

But when I use these optional features, rust-analyzer doesnt handle my optional feature related code. No hint, no error checking. If I use them it as a default feature, then its ok, but then I need to use default_features = false in the the project where it is a dependency.

So is there any way to not use default features, just optional ones, and somehow force rust-analyzer to handle the optional code as well - during the development?

Here is my cargo.toml part

default = ["proto", "id"]
id = []
proto = ["futures", "prost", "tokio", "tonic"]

futures = {version = "0.3.5", optional = true}
prost = {version = "0.6", optional = true}
tokio = {version = "0.2", features = ["macros"], optional = true}
tonic = {version = "0.3.1", optional = true}

and here is my

#[cfg(feature = "id")]
pub mod id;
pub mod prelude;
#[cfg(feature = "proto")]
pub mod proto;

and here is the project:

Thank you in advance!

I believe you'll need to configure the features that RA activates via rust-analyzer.cargo.features (a collection (list/array/...) of feature names) and/or rust-analyzer.cargo.allFeatures (bool).

See the user manual's configuration section for more details.


Thank you! It works! :heart: