Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/rust-analyzer/src/config.rs3
-rw-r--r--crates/rust-analyzer/src/handlers/request.rs8
-rw-r--r--crates/rust-analyzer/src/target_spec.rs4
3 files changed, 15 insertions, 0 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 736e648938..ff1b9e0eb9 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -1688,6 +1688,8 @@ pub struct RunnablesConfig {
pub override_cargo: Option<String>,
/// Additional arguments for the `cargo`, e.g. `--release`.
pub cargo_extra_args: Vec<String>,
+ /// Path to an extra config file passed to cargo via `--config`.
+ pub config_path: Option<AbsPathBuf>,
/// Additional arguments for the binary being run, if it is a test or benchmark.
pub extra_test_binary_args: Vec<String>,
/// Subcommand used for doctest runnables instead of `test`.
@@ -2669,6 +2671,7 @@ impl Config {
RunnablesConfig {
override_cargo: self.runnables_command(source_root).clone(),
cargo_extra_args: self.runnables_extraArgs(source_root).clone(),
+ config_path: self.cargo_config_path(source_root),
extra_test_binary_args: self.runnables_extraTestBinaryArgs(source_root).clone(),
test_command: self.runnables_test_command(source_root).clone(),
test_override_command: self.runnables_test_overrideCommand(source_root).clone(),
diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs
index 9710a19d69..e57b05660d 100644
--- a/crates/rust-analyzer/src/handlers/request.rs
+++ b/crates/rust-analyzer/src/handlers/request.rs
@@ -1074,6 +1074,10 @@ pub(crate) fn handle_runnables(
cargo_args.push("--all-targets".to_owned());
}
cargo_args.extend(config.cargo_extra_args.iter().cloned());
+ if let Some(config_path) = &config.config_path {
+ cargo_args.push("--config".to_owned());
+ cargo_args.push(config_path.to_string());
+ }
res.push(lsp_ext::Runnable {
label: format!(
"cargo {cmd} -p {}{all_targets}",
@@ -1104,6 +1108,10 @@ pub(crate) fn handle_runnables(
{
let mut cargo_args = vec!["check".to_owned(), "--workspace".to_owned()];
cargo_args.extend(config.cargo_extra_args.iter().cloned());
+ if let Some(config_path) = &config.config_path {
+ cargo_args.push("--config".to_owned());
+ cargo_args.push(config_path.to_string());
+ }
res.push(lsp_ext::Runnable {
label: "cargo check --workspace".to_owned(),
location: None,
diff --git a/crates/rust-analyzer/src/target_spec.rs b/crates/rust-analyzer/src/target_spec.rs
index fdcd2c98b9..7c957603de 100644
--- a/crates/rust-analyzer/src/target_spec.rs
+++ b/crates/rust-analyzer/src/target_spec.rs
@@ -204,6 +204,10 @@ impl CargoTargetSpec {
}
}
cargo_args.extend(config.cargo_extra_args.iter().cloned());
+ if let Some(config_path) = &config.config_path {
+ cargo_args.push("--config".to_owned());
+ cargo_args.push(config_path.to_string());
+ }
(cargo_args, executable_args)
}