diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2024-12-26 15:28:24 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-26 15:28:24 +0000 |
| commit | bae8fb5c8074d2fb478b6f124dacf4b8b5f42d62 (patch) | |
| tree | 60fa8a2673176a1fd51d1fb4ff3ff65328d6cb7b | |
| parent | ec5e4855cc43cf4a7d240312ae1827b1e63ad09d (diff) | |
| parent | 5290f20f08b325b948ee5b9e2701f07b522da077 (diff) | |
| download | rust-bae8fb5c8074d2fb478b6f124dacf4b8b5f42d62.tar.gz rust-bae8fb5c8074d2fb478b6f124dacf4b8b5f42d62.zip | |
Merge pull request #18761 from Veykril/push-vktnzltnxupr
internal: Swallow `error: config value is not set` cargo error
| -rw-r--r-- | src/tools/rust-analyzer/crates/project-model/src/target_triple.rs | 13 |
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>> { |
