Skip to content

Can't specify features for individual crates in a virtual workspace #5383

@Michael-F-Bryan

Description

@Michael-F-Bryan

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-unactionableIssue requires feedback, design decisions or is blocked on other work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions