-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
When you have a workspace containing multiple crates in subdirectories and those crates have their own feature flags, it's not possible to specify which feature flags to use when checking/navigating that project.
Setting rust-analyzer.cargo.features
doesn't work because cargo errors with "error: --features is not allowed in the root of a virtual workspace
", same as if I ran cargo check --features foo
from the workspace root.
This becomes particularly evident if you are continuously recompiling and running tests in a background terminal (e.g. cd sub-crate && cargo watch -x "check --features foo"
). Rust Analyzer ends up compiling the crate/workspace without the feature and cargo watch
compiles with it. That means you'll constantly be rebuilding the entire crate... Which can be quite expensive when the feature flag enables several transitive dependencies (e.g. tokio
and a HTTP server).