Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #17929 - Veykril:invocation-loc-docs, r=Veykril
minor: Improve documentation for `InvocationStrategy` cc https://github.com/rust-lang/rust-analyzer/pull/17888
bors 2024-08-19
parent 0c395dc · parent 3c4cdbb · commit c9955bf
-rw-r--r--crates/project-model/src/build_dependencies.rs7
-rw-r--r--crates/project-model/src/workspace.rs19
-rw-r--r--crates/rust-analyzer/src/config.rs10
-rw-r--r--docs/user/generated_config.adoc6
-rw-r--r--editors/code/package.json10
5 files changed, 29 insertions, 23 deletions
diff --git a/crates/project-model/src/build_dependencies.rs b/crates/project-model/src/build_dependencies.rs
index 25d1ea07aa..dc71b13eee 100644
--- a/crates/project-model/src/build_dependencies.rs
+++ b/crates/project-model/src/build_dependencies.rs
@@ -82,17 +82,16 @@ impl WorkspaceBuildScripts {
config: &CargoConfig,
workspaces: &[&CargoWorkspace],
progress: &dyn Fn(String),
- workspace_root: &AbsPathBuf,
+ working_directory: &AbsPathBuf,
) -> io::Result<Vec<WorkspaceBuildScripts>> {
assert_eq!(config.invocation_strategy, InvocationStrategy::Once);
- let current_dir = workspace_root;
let cmd = Self::build_command(
config,
&Default::default(),
// This is not gonna be used anyways, so just construct a dummy here
- &ManifestPath::try_from(workspace_root.clone()).unwrap(),
- current_dir,
+ &ManifestPath::try_from(working_directory.clone()).unwrap(),
+ working_directory,
&Sysroot::empty(),
)?;
// NB: Cargo.toml could have been modified between `cargo metadata` and
diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs
index c6be91229f..33ba7f9688 100644
--- a/crates/project-model/src/workspace.rs
+++ b/crates/project-model/src/workspace.rs
@@ -459,7 +459,7 @@ impl ProjectWorkspace {
workspaces: &[ProjectWorkspace],
config: &CargoConfig,
progress: &dyn Fn(String),
- workspace_root: &AbsPathBuf,
+ working_directory: &AbsPathBuf,
) -> Vec<anyhow::Result<WorkspaceBuildScripts>> {
if matches!(config.invocation_strategy, InvocationStrategy::PerWorkspace)
|| config.run_build_script_command.is_none()
@@ -474,13 +474,16 @@ impl ProjectWorkspace {
_ => None,
})
.collect();
- let outputs =
- &mut match WorkspaceBuildScripts::run_once(config, &cargo_ws, progress, workspace_root)
- {
- Ok(it) => Ok(it.into_iter()),
- // io::Error is not Clone?
- Err(e) => Err(sync::Arc::new(e)),
- };
+ let outputs = &mut match WorkspaceBuildScripts::run_once(
+ config,
+ &cargo_ws,
+ progress,
+ working_directory,
+ ) {
+ Ok(it) => Ok(it.into_iter()),
+ // io::Error is not Clone?
+ Err(e) => Err(sync::Arc::new(e)),
+ };
workspaces
.iter()
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 680a500eaa..d7f24e6ce1 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -81,8 +81,10 @@ config_data! {
/// Run build scripts (`build.rs`) for more precise code analysis.
cargo_buildScripts_enable: bool = true,
/// Specifies the invocation strategy to use when running the build scripts command.
- /// If `per_workspace` is set, the command will be executed for each workspace.
- /// If `once` is set, the command will be executed once.
+ /// If `per_workspace` is set, the command will be executed for each Rust workspace with the
+ /// workspace as the working directory.
+ /// If `once` is set, the command will be executed once with the opened project as the
+ /// working directory.
/// This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
/// is set.
cargo_buildScripts_invocationStrategy: InvocationStrategy = InvocationStrategy::PerWorkspace,
@@ -3154,8 +3156,8 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
"type": "string",
"enum": ["per_workspace", "once"],
"enumDescriptions": [
- "The command will be executed for each workspace.",
- "The command will be executed once."
+ "The command will be executed for each Rust workspace with the workspace as the working directory.",
+ "The command will be executed once with the opened project as the working directory."
],
},
"Option<CheckOnSaveTargets>" => set! {
diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc
index 647cf3db4a..e4a8c6493a 100644
--- a/docs/user/generated_config.adoc
+++ b/docs/user/generated_config.adoc
@@ -49,8 +49,10 @@ Run build scripts (`build.rs`) for more precise code analysis.
+
--
Specifies the invocation strategy to use when running the build scripts command.
-If `per_workspace` is set, the command will be executed for each workspace.
-If `once` is set, the command will be executed once.
+If `per_workspace` is set, the command will be executed for each Rust workspace with the
+workspace as the working directory.
+If `once` is set, the command will be executed once with the opened project as the
+working directory.
This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`
is set.
--
diff --git a/editors/code/package.json b/editors/code/package.json
index 9c2c227319..98e8bbf02a 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -667,7 +667,7 @@
"title": "cargo",
"properties": {
"rust-analyzer.cargo.buildScripts.invocationStrategy": {
- "markdownDescription": "Specifies the invocation strategy to use when running the build scripts command.\nIf `per_workspace` is set, the command will be executed for each workspace.\nIf `once` is set, the command will be executed once.\nThis config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`\nis set.",
+ "markdownDescription": "Specifies the invocation strategy to use when running the build scripts command.\nIf `per_workspace` is set, the command will be executed for each Rust workspace with the\nworkspace as the working directory.\nIf `once` is set, the command will be executed once with the opened project as the\nworking directory.\nThis config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#`\nis set.",
"default": "per_workspace",
"type": "string",
"enum": [
@@ -675,8 +675,8 @@
"once"
],
"enumDescriptions": [
- "The command will be executed for each workspace.",
- "The command will be executed once."
+ "The command will be executed for each Rust workspace with the workspace as the working directory.",
+ "The command will be executed once with the opened project as the working directory."
]
}
}
@@ -959,8 +959,8 @@
"once"
],
"enumDescriptions": [
- "The command will be executed for each workspace.",
- "The command will be executed once."
+ "The command will be executed for each Rust workspace with the workspace as the working directory.",
+ "The command will be executed once with the opened project as the working directory."
]
}
}