From 516a1b47b4ac4c4201e955a8a4dfc28bf605e109 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 25 Jul 2024 12:28:31 +0200 Subject: [PATCH] fix: Support new cargo config get env format --- .../crates/project-model/src/env.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/tools/rust-analyzer/crates/project-model/src/env.rs b/src/tools/rust-analyzer/crates/project-model/src/env.rs index 88fb10a68c61..3df46e1e37d9 100644 --- a/src/tools/rust-analyzer/crates/project-model/src/env.rs +++ b/src/tools/rust-analyzer/crates/project-model/src/env.rs @@ -75,14 +75,26 @@ pub(crate) fn cargo_config_env( } // if successful we receive `env.key.value = "value" per entry tracing::debug!("Discovering cargo config env by {:?}", cargo_config); - utf8_stdout(cargo_config).map(parse_output_cargo_config_env).unwrap_or_default() + utf8_stdout(cargo_config) + .map(parse_output_cargo_config_env) + .inspect(|env| { + tracing::debug!("Discovered cargo config env: {:?}", env); + }) + .inspect_err(|err| { + tracing::error!("Failed to discover cargo config env: {:?}", err); + }) + .unwrap_or_default() } fn parse_output_cargo_config_env(stdout: String) -> FxHashMap { stdout .lines() .filter_map(|l| l.strip_prefix("env.")) - .filter_map(|l| l.split_once(".value = ")) + .filter_map(|l| { + l.split_once(" = ") + // cargo used to report it with this, keep it for a couple releases around + .or_else(|| l.split_once(".value = ")) + }) .map(|(key, value)| (key.to_owned(), value.trim_matches('"').to_owned())) .collect() }