about summary refs log tree commit diff
path: root/src/tools/rust-analyzer
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2024-12-26 16:13:11 +0100
committerLukas Wirth <lukastw97@gmail.com>2024-12-26 16:13:39 +0100
commit5290f20f08b325b948ee5b9e2701f07b522da077 (patch)
tree28897379af8cf009594dccf832c6505fb4893ed0 /src/tools/rust-analyzer
parent022bece913ef6dfd1010b127ac5fda9db7cd0ece (diff)
downloadrust-5290f20f08b325b948ee5b9e2701f07b522da077.tar.gz
rust-5290f20f08b325b948ee5b9e2701f07b522da077.zip
internal: Swallow `error: config value is not set` cargo error
Diffstat (limited to 'src/tools/rust-analyzer')
-rw-r--r--src/tools/rust-analyzer/crates/project-model/src/target_triple.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/tools/rust-analyzer/crates/project-model/src/target_triple.rs b/src/tools/rust-analyzer/crates/project-model/src/target_triple.rs
index 92e0c49885f..4a32212097d 100644
--- a/src/tools/rust-analyzer/crates/project-model/src/target_triple.rs
+++ b/src/tools/rust-analyzer/crates/project-model/src/target_triple.rs
@@ -23,11 +23,8 @@ pub(super) fn get(
     let sysroot = match config {
         TargetTipleConfig::Cargo(sysroot, cargo_toml) => {
             match cargo_config_build_target(cargo_toml, extra_env, sysroot) {
-                Ok(it) => return Ok(it),
-                Err(e) => {
-                    tracing::warn!("failed to run `cargo rustc --print cfg`, falling back to invoking rustc directly: {e}");
-                    sysroot
-                }
+                Some(it) => return Ok(it),
+                None => sysroot,
             }
         }
         TargetTipleConfig::Rustc(sysroot) => sysroot,
@@ -58,7 +55,7 @@ fn cargo_config_build_target(
     cargo_toml: &ManifestPath,
     extra_env: &FxHashMap<String, String>,
     sysroot: &Sysroot,
-) -> anyhow::Result<Vec<String>> {
+) -> Option<Vec<String>> {
     let mut cargo_config = sysroot.tool(Tool::Cargo);
     cargo_config.envs(extra_env);
     cargo_config
@@ -68,7 +65,9 @@ fn cargo_config_build_target(
     // if successful we receive `build.target = "target-triple"`
     // or `build.target = ["<target 1>", ..]`
     tracing::debug!("Discovering cargo config target by {:?}", cargo_config);
-    utf8_stdout(cargo_config).and_then(parse_output_cargo_config_build_target)
+    // this might be `error: config value `build.target` is not set` in which case we
+    // don't wanna log the error
+    utf8_stdout(cargo_config).and_then(parse_output_cargo_config_build_target).ok()
 }
 
 fn parse_output_cargo_config_build_target(stdout: String) -> anyhow::Result<Vec<String>> {