Skip to content

Commit 108138d

Browse files
committed
refactor(config)!: return LocalToolchainName from find_or_install_active_toolchain()
1 parent d2c9b1c commit 108138d

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/cli/rustup_mode.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -867,10 +867,7 @@ async fn update(
867867
}
868868
} else if ensure_active_toolchain {
869869
let (toolchain, reason) = cfg.find_or_install_active_toolchain(true).await?;
870-
info!(
871-
"the active toolchain `{}` has been installed",
872-
toolchain.name()
873-
);
870+
info!("the active toolchain `{toolchain}` has been installed");
874871
info!("it's active because: {reason}");
875872
} else {
876873
exit_code &= common::update_all_channels(cfg, self_update, opts.force).await?;

src/config.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -741,18 +741,18 @@ impl<'a> Cfg<'a> {
741741

742742
#[tracing::instrument(level = "trace", skip_all)]
743743
pub(crate) async fn find_or_install_active_toolchain(
744-
&'a self,
744+
&self,
745745
verbose: bool,
746-
) -> Result<(Toolchain<'a>, ActiveReason)> {
746+
) -> Result<(LocalToolchainName, ActiveReason)> {
747747
match self.find_override_config()? {
748748
Some((override_config, reason)) => match override_config {
749749
OverrideCfg::PathBased(path_based_name) => {
750750
let toolchain = Toolchain::with_reason(self, path_based_name.into(), &reason)?;
751-
Ok((toolchain, reason))
751+
Ok((toolchain.name().clone(), reason))
752752
}
753753
OverrideCfg::Custom(custom_name) => {
754754
let toolchain = Toolchain::with_reason(self, custom_name.into(), &reason)?;
755-
Ok((toolchain, reason))
755+
Ok((toolchain.name().clone(), reason))
756756
}
757757
OverrideCfg::Official {
758758
toolchain,
@@ -764,23 +764,23 @@ impl<'a> Cfg<'a> {
764764
.ensure_installed(&toolchain, components, targets, profile, verbose)
765765
.await?
766766
.1;
767-
Ok((toolchain, reason))
767+
Ok((toolchain.name().clone(), reason))
768768
}
769769
},
770770
None => match self.get_default()? {
771771
None => Err(no_toolchain_error(self.process)),
772772
Some(ToolchainName::Custom(custom_name)) => {
773773
let reason = ActiveReason::Default;
774774
let toolchain = Toolchain::with_reason(self, custom_name.into(), &reason)?;
775-
Ok((toolchain, reason))
775+
Ok((toolchain.name().clone(), reason))
776776
}
777777
Some(ToolchainName::Official(toolchain_desc)) => {
778778
let reason = ActiveReason::Default;
779779
let toolchain = self
780780
.ensure_installed(&toolchain_desc, vec![], vec![], None, verbose)
781781
.await?
782782
.1;
783-
Ok((toolchain, reason))
783+
Ok((toolchain.name().clone(), reason))
784784
}
785785
},
786786
}

0 commit comments

Comments
 (0)