-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't specify features for individual crates in a virtual workspace #5383
Comments
If you are running cargo watch anyway, you should set rust-analyzer.checkOnSave.enable: false. Cargo watch should still provide you with inline error markers, via the problem matcher. |
Does the problem matcher need |
You need to run it as a vscode task, the following definition should work {
"label": "Watch",
"group": "build",
"type": "shell",
"command": "cargo watch --package rust-analyzer",
"problemMatcher": "$rustc-watch",
"isBackground": true
}, |
This is a Cargo limitation that will be addressed by rust-lang/rfcs#2957. |
I belive this was fixed on the cargo side with the introduction of resolver=2 |
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 rancargo 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 andcargo 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).The text was updated successfully, but these errors were encountered: