Can --workspace
be removed from cargo check
?
#10717
Labels
A-config
configuration
C-feature
Category: feature request
S-actionable
Someone could pick this issue up and work on it right now
When running build scripts in the workspace,
--workspace
flag is used unconditionally. Even withrust-analyzer.cargo.noDefaultFeatures=true
specified, this flag causes crates markedoptional = true
to be compiled (the feature for the crate is not turned on).cargo help check
says this:Currently, the only workaround is to specify the following:
However, this is a hack and a really big hammer which stops all uses of build scripts in the workspace. If
--workspace
flag is removed, the optional dependencies are ignored (for unspecified features) as expected.I believe this behavior is problematic especially if
rust-analyzer.cargo.noDefaultFeatures
is set totrue
.rust-analyzer.cargo.noDefaultFeatures=true
would be a good hint that the user doesn't want to compile everything in the workspace, but only some of the features.Use case
In our internal project, a project has
windows
andlinux
specific dependencies. Some crates are linux only, they have build scripts which only work on linux. They are specified inCargo.toml
behindfeature
configuration. As long as the relevant feature is not turned on, those crates are not compiled. The dependencies are path specific and markedoptional = true
. Usingrust-analyzer
on this workspace will callcargo check --workspace
which runs build scripts for dependencies including optional ones. This makesrust-analyzer
status always broken.The text was updated successfully, but these errors were encountered: