Skip to content

Commit e6bd7a6

Browse files
committed
Ignore invalid paths from --print=rustc-path
This allows existing tests to work without stubbing --print=rustc-path.
1 parent c477ebd commit e6bd7a6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/cargo/util/rustc.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,18 @@ impl Rustc {
4747
let _p = profile::start("Rustc::new");
4848

4949
// In order to avoid calling through rustup multiple times, we first ask
50-
// rustc to give us the "resolved" rustc path, and use that instead.
50+
// rustc to give us the "resolved" rustc path, and use that instead. If
51+
// this doesn't give us a path, then we just use the original path such
52+
// that the following logic can handle any resulting errors normally.
5153
let mut cmd = ProcessBuilder::new(&path);
5254
cmd.arg("--print=rustc-path");
5355
if let Ok(output) = cmd.output() {
5456
if output.status.success() {
5557
if let Ok(resolved) = String::from_utf8(output.stdout) {
56-
path = PathBuf::from(resolved.trim());
58+
let resolved = PathBuf::from(resolved.trim());
59+
if resolved.exists() {
60+
path = resolved;
61+
}
5762
}
5863
}
5964
}

0 commit comments

Comments
 (0)