mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Auto merge of #16924 - poliorcetics:ab/push-kxwqvtypvlsq, r=Veykril
feat: Add `rust-analyzer.cargo.allTargets` to configure passing `--all-targets` to cargo invocations Closes #16859 ## Unresolved question: Should this be a setting for build scripts only ? All the other `--all-targets` I found where already covered by `checkOnSave.allTargets`
This commit is contained in:
commit
2678660880
5 changed files with 31 additions and 9 deletions
|
@ -86,7 +86,9 @@ impl WorkspaceBuildScripts {
|
|||
// --all-targets includes tests, benches and examples in addition to the
|
||||
// default lib and bins. This is an independent concept from the --target
|
||||
// flag below.
|
||||
cmd.arg("--all-targets");
|
||||
if config.all_targets {
|
||||
cmd.arg("--all-targets");
|
||||
}
|
||||
|
||||
if let Some(target) = &config.target {
|
||||
cmd.args(["--target", target]);
|
||||
|
|
|
@ -76,6 +76,8 @@ impl Default for CargoFeatures {
|
|||
|
||||
#[derive(Default, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CargoConfig {
|
||||
/// Whether to pass `--all-targets` to cargo invocations.
|
||||
pub all_targets: bool,
|
||||
/// List of features to activate.
|
||||
pub features: CargoFeatures,
|
||||
/// rustc target
|
||||
|
|
|
@ -71,6 +71,9 @@ config_data! {
|
|||
/// How many worker threads to handle priming caches. The default `0` means to pick automatically.
|
||||
cachePriming_numThreads: ParallelCachePrimingNumThreads = "0",
|
||||
|
||||
/// Pass `--all-targets` to cargo invocation. Overridden by `#rust-analyzer.check.allTargets#`
|
||||
/// when the latter is set.
|
||||
cargo_allTargets: bool = "true",
|
||||
/// Automatically refresh project info via `cargo metadata` on
|
||||
/// `Cargo.toml` or `.cargo/config.toml` changes.
|
||||
cargo_autoreload: bool = "true",
|
||||
|
@ -163,8 +166,8 @@ config_data! {
|
|||
/// Run the check command for diagnostics on save.
|
||||
checkOnSave | checkOnSave_enable: bool = "true",
|
||||
|
||||
/// Check all targets and tests (`--all-targets`).
|
||||
check_allTargets | checkOnSave_allTargets: bool = "true",
|
||||
/// Check all targets and tests (`--all-targets`). Overrides `#rust-analyzer.cargo.allTargets#`.
|
||||
check_allTargets | checkOnSave_allTargets: Option<bool> = "null",
|
||||
/// Cargo command to use for `cargo check`.
|
||||
check_command | checkOnSave_command: String = "\"check\"",
|
||||
/// Extra arguments for `cargo check`.
|
||||
|
@ -1284,6 +1287,7 @@ impl Config {
|
|||
let sysroot_query_metadata = self.data.cargo_sysrootQueryMetadata;
|
||||
|
||||
CargoConfig {
|
||||
all_targets: self.data.cargo_allTargets,
|
||||
features: match &self.data.cargo_features {
|
||||
CargoFeaturesDef::All => CargoFeatures::All,
|
||||
CargoFeaturesDef::Selected(features) => CargoFeatures::Selected {
|
||||
|
@ -1394,7 +1398,7 @@ impl Config {
|
|||
targets => Some(targets.into()),
|
||||
})
|
||||
.unwrap_or_else(|| self.data.cargo_target.clone().into_iter().collect()),
|
||||
all_targets: self.data.check_allTargets,
|
||||
all_targets: self.data.check_allTargets.unwrap_or(self.data.cargo_allTargets),
|
||||
no_default_features: self
|
||||
.data
|
||||
.check_noDefaultFeatures
|
||||
|
|
|
@ -19,6 +19,12 @@ Warm up caches on project load.
|
|||
--
|
||||
How many worker threads to handle priming caches. The default `0` means to pick automatically.
|
||||
--
|
||||
[[rust-analyzer.cargo.allTargets]]rust-analyzer.cargo.allTargets (default: `true`)::
|
||||
+
|
||||
--
|
||||
Pass `--all-targets` to cargo invocation. Overridden by `#rust-analyzer.check.allTargets#`
|
||||
when the latter is set.
|
||||
--
|
||||
[[rust-analyzer.cargo.autoreload]]rust-analyzer.cargo.autoreload (default: `true`)::
|
||||
+
|
||||
--
|
||||
|
@ -164,10 +170,10 @@ Unsets the implicit `#[cfg(test)]` for the specified crates.
|
|||
--
|
||||
Run the check command for diagnostics on save.
|
||||
--
|
||||
[[rust-analyzer.check.allTargets]]rust-analyzer.check.allTargets (default: `true`)::
|
||||
[[rust-analyzer.check.allTargets]]rust-analyzer.check.allTargets (default: `null`)::
|
||||
+
|
||||
--
|
||||
Check all targets and tests (`--all-targets`).
|
||||
Check all targets and tests (`--all-targets`). Overrides `#rust-analyzer.cargo.allTargets#`.
|
||||
--
|
||||
[[rust-analyzer.check.command]]rust-analyzer.check.command (default: `"check"`)::
|
||||
+
|
||||
|
|
|
@ -546,6 +546,11 @@
|
|||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"rust-analyzer.cargo.allTargets": {
|
||||
"markdownDescription": "Pass `--all-targets` to cargo invocation. Overridden by `#rust-analyzer.check.allTargets#`\nwhen the latter is set.",
|
||||
"default": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
"rust-analyzer.cargo.autoreload": {
|
||||
"markdownDescription": "Automatically refresh project info via `cargo metadata` on\n`Cargo.toml` or `.cargo/config.toml` changes.",
|
||||
"default": true,
|
||||
|
@ -707,9 +712,12 @@
|
|||
"type": "boolean"
|
||||
},
|
||||
"rust-analyzer.check.allTargets": {
|
||||
"markdownDescription": "Check all targets and tests (`--all-targets`).",
|
||||
"default": true,
|
||||
"type": "boolean"
|
||||
"markdownDescription": "Check all targets and tests (`--all-targets`). Overrides `#rust-analyzer.cargo.allTargets#`.",
|
||||
"default": null,
|
||||
"type": [
|
||||
"null",
|
||||
"boolean"
|
||||
]
|
||||
},
|
||||
"rust-analyzer.check.command": {
|
||||
"markdownDescription": "Cargo command to use for `cargo check`.",
|
||||
|
|
Loading…
Reference in a new issue