Skip to content

Commit 2c58dca

Browse files
committed
Move proxy toolchain resolution logic into Cfg method
1 parent 8f1a1a1 commit 2c58dca

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/cli/proxy_mode.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::{path::PathBuf, process::ExitStatus};
22

33
use anyhow::Result;
44

5-
use crate::toolchain::toolchain::Toolchain;
65
use crate::{
76
cli::{common::set_globals, job, self_update},
87
command::run_command_for_dir,
@@ -34,15 +33,6 @@ pub async fn main(arg0: &str, current_dir: PathBuf, process: &Process) -> Result
3433

3534
let cfg = set_globals(current_dir, false, true, process)?;
3635
cfg.check_metadata_version()?;
37-
let toolchain = toolchain
38-
.map(|t| t.resolve(&cfg.get_default_host_triple()?))
39-
.transpose()?;
40-
41-
let toolchain = match toolchain {
42-
None => cfg.find_or_install_active_toolchain().await?.0,
43-
Some(tc) => Toolchain::from_local(tc, false, &cfg).await?,
44-
};
45-
46-
let cmd = toolchain.command(arg0)?;
36+
let cmd = cfg.local_toolchain(toolchain).await?.command(arg0)?;
4737
run_command_for_dir(cmd, arg0, &cmd_args)
4838
}

src/config.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,20 @@ impl<'a> Cfg<'a> {
716716
.rustc_version())
717717
}
718718

719+
pub(crate) async fn local_toolchain(
720+
&self,
721+
name: Option<ResolvableLocalToolchainName>,
722+
) -> Result<Toolchain<'_>> {
723+
let local = name
724+
.map(|name| name.resolve(&self.get_default_host_triple()?))
725+
.transpose()?;
726+
727+
Ok(match local {
728+
Some(tc) => Toolchain::from_local(tc, false, self).await?,
729+
None => self.find_or_install_active_toolchain().await?.0,
730+
})
731+
}
732+
719733
pub(crate) async fn find_or_install_active_toolchain(
720734
&'a self,
721735
) -> Result<(Toolchain<'a>, ActiveReason)> {

0 commit comments

Comments
 (0)