Skip to content

Commit 5290f20

Browse files
committed
internal: Swallow error: config value is not set cargo error
1 parent 022bece commit 5290f20

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/tools/rust-analyzer/crates/project-model/src/target_triple.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ pub(super) fn get(
2323
let sysroot = match config {
2424
TargetTipleConfig::Cargo(sysroot, cargo_toml) => {
2525
match cargo_config_build_target(cargo_toml, extra_env, sysroot) {
26-
Ok(it) => return Ok(it),
27-
Err(e) => {
28-
tracing::warn!("failed to run `cargo rustc --print cfg`, falling back to invoking rustc directly: {e}");
29-
sysroot
30-
}
26+
Some(it) => return Ok(it),
27+
None => sysroot,
3128
}
3229
}
3330
TargetTipleConfig::Rustc(sysroot) => sysroot,
@@ -58,7 +55,7 @@ fn cargo_config_build_target(
5855
cargo_toml: &ManifestPath,
5956
extra_env: &FxHashMap<String, String>,
6057
sysroot: &Sysroot,
61-
) -> anyhow::Result<Vec<String>> {
58+
) -> Option<Vec<String>> {
6259
let mut cargo_config = sysroot.tool(Tool::Cargo);
6360
cargo_config.envs(extra_env);
6461
cargo_config
@@ -68,7 +65,9 @@ fn cargo_config_build_target(
6865
// if successful we receive `build.target = "target-triple"`
6966
// or `build.target = ["<target 1>", ..]`
7067
tracing::debug!("Discovering cargo config target by {:?}", cargo_config);
71-
utf8_stdout(cargo_config).and_then(parse_output_cargo_config_build_target)
68+
// this might be `error: config value `build.target` is not set` in which case we
69+
// don't wanna log the error
70+
utf8_stdout(cargo_config).and_then(parse_output_cargo_config_build_target).ok()
7271
}
7372

7473
fn parse_output_cargo_config_build_target(stdout: String) -> anyhow::Result<Vec<String>> {

0 commit comments

Comments
 (0)