Skip to content

Commit

Permalink
Don't early return when we can't find rustup proxy exe
Browse files Browse the repository at this point in the history
This fixes a bug introduced during the futures rewrite - we eagerly
returned from the function rather than, as we did originally, falling
back to compiling without proxy.
  • Loading branch information
Xanewok committed Apr 13, 2021
1 parent f79c6f6 commit 1ebbe5d
Showing 1 changed file with 45 additions and 29 deletions.
74 changes: 45 additions & 29 deletions src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,49 +894,65 @@ where
None
};

let creator1 = creator.clone();
let executable = executable.to_owned();
let executable2 = executable.clone();
let pool = pool.clone();
let cwd = cwd.to_owned();
match rustc_vv {
Some(Ok(rustc_verbose_version)) => {
debug!("Found rustc");

let proxy = RustupProxy::find_proxy_executable::<T>(
&executable,
&executable2,
"rustup",
creator.clone(),
&env,
)
.await?;

let (proxy, resolved_rustc) = match proxy {
Ok(Some(proxy)) => {
trace!("Found rustup proxy executable");
// take the pathbuf for rustc as resolved by the proxy
match proxy
.resolve_proxied_executable(creator.clone(), cwd, &env)
.await
{
Ok((resolved_path, _time)) => {
trace!("Resolved path with rustup proxy {:?}", &resolved_path);
let proxy = Box::new(proxy) as Box<dyn CompilerProxy<T>>;
(Some(proxy), resolved_path)
}
Err(e) => {
trace!("Could not resolve compiler with rustup proxy: {}", e);
(None, executable)
);
use futures::TryFutureExt;
let res = proxy.and_then(move |proxy| async move {
match proxy {
Ok(Some(proxy)) => {
trace!("Found rustup proxy executable");
// take the pathbuf for rustc as resolved by the proxy
match proxy
.resolve_proxied_executable(creator1, cwd, &env)
.await
{
Ok((resolved_path, _time)) => {
trace!("Resolved path with rustup proxy {:?}", &resolved_path);
Ok((Some(proxy), resolved_path))
}
Err(e) => {
trace!("Could not resolve compiler with rustup proxy: {}", e);
Ok((None, executable))
}
}
}
Ok(None) => {
trace!("Did not find rustup");
Ok((None, executable))
}
Err(e) => {
trace!("Did not find rustup due to {}, compiling without proxy", e);
Ok((None, executable))
}
}
Ok(None) => {
trace!("Did not find rustup");
(None, executable)
}
Err(e) => {
trace!("Did not find rustup due to {}, compiling without proxy", e);
(None, executable)
}
};
});

let (proxy, resolved_rustc) = res.await
.map(|(proxy,resolved_compiler_executable)| {
(
proxy.map(Box::new).map(|x : Box<RustupProxy>| {
x as Box<dyn CompilerProxy<T>>
}),
resolved_compiler_executable
)
})
.unwrap_or_else(|_e| {
trace!("Compiling rust without proxy");
(None, executable2)
});

Rust::new(
creator,
Expand Down

0 comments on commit 1ebbe5d

Please sign in to comment.