Skip to content

Commit

Permalink
Ignore invalid paths from --print=rustc-path
Browse files Browse the repository at this point in the history
This allows existing tests to work without stubbing --print=rustc-path.
  • Loading branch information
CAD97 committed Aug 21, 2022
1 parent eb9685d commit 40bcc08
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/cargo/util/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,18 @@ impl Rustc {
let _p = profile::start("Rustc::new");

// In order to avoid calling through rustup multiple times, we first ask
// rustc to give us the "resolved" rustc path, and use that instead.
// rustc to give us the "resolved" rustc path, and use that instead. If
// this doesn't give us a path, then we just use the original path such
// that the following logic can handle any resulting errors normally.
let mut cmd = ProcessBuilder::new(&path);
cmd.arg("--print=rustc-path");
if let Ok(output) = cmd.output() {
if output.status.success() {
if let Ok(resolved) = String::from_utf8(output.stdout) {
path = PathBuf::from(resolved.trim());
let resolved = PathBuf::from(resolved.trim());
if resolved.exists() {
path = resolved;
}
}
}
}
Expand Down

0 comments on commit 40bcc08

Please sign in to comment.