Skip to content

Commit 8df6d01

Browse files
committed
refactor(config)!: pass the force_non_host flag to Cfg::ensure_installed()
1 parent d407001 commit 8df6d01

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/cli/rustup_mode.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ async fn default_(
725725
MaybeResolvableToolchainName::Some(ResolvableToolchainName::Official(toolchain)) => {
726726
let desc = toolchain.resolve(&cfg.get_default_host_triple()?)?;
727727
let status = cfg
728-
.ensure_installed(&desc, vec![], vec![], None, true)
728+
.ensure_installed(&desc, vec![], vec![], None, false, true)
729729
.await?
730730
.0;
731731

@@ -878,7 +878,9 @@ async fn update(
878878
exit_code &= common::self_update(|| Ok(()), cfg.process).await?;
879879
}
880880
} else if ensure_active_toolchain {
881-
let (toolchain, reason) = cfg.find_or_install_active_toolchain(true).await?;
881+
let (toolchain, reason) = cfg
882+
.find_or_install_active_toolchain(force_non_host, true)
883+
.await?;
882884
info!("the active toolchain `{toolchain}` has been installed");
883885
info!("it's active because: {reason}");
884886
} else {

src/config.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ impl<'a> Cfg<'a> {
742742
#[tracing::instrument(level = "trace", skip_all)]
743743
pub(crate) async fn find_or_install_active_toolchain(
744744
&self,
745+
force_non_host: bool,
745746
verbose: bool,
746747
) -> Result<(LocalToolchainName, ActiveReason)> {
747748
if let Some((override_config, reason)) = self.find_override_config()? {
@@ -753,16 +754,23 @@ impl<'a> Cfg<'a> {
753754
profile,
754755
} = override_config
755756
{
756-
self.ensure_installed(&toolchain, components, targets, profile, verbose)
757-
.await?;
757+
self.ensure_installed(
758+
&toolchain,
759+
components,
760+
targets,
761+
profile,
762+
force_non_host,
763+
verbose,
764+
)
765+
.await?;
758766
} else {
759767
Toolchain::with_reason(self, toolchain.clone(), &reason)?;
760768
}
761769
Ok((toolchain, reason))
762770
} else if let Some(toolchain) = self.get_default()? {
763771
let reason = ActiveReason::Default;
764772
if let ToolchainName::Official(desc) = &toolchain {
765-
self.ensure_installed(desc, vec![], vec![], None, verbose)
773+
self.ensure_installed(desc, vec![], vec![], None, force_non_host, verbose)
766774
.await?;
767775
} else {
768776
Toolchain::with_reason(self, toolchain.clone().into(), &reason)?;
@@ -782,13 +790,14 @@ impl<'a> Cfg<'a> {
782790
components: Vec<String>,
783791
targets: Vec<String>,
784792
profile: Option<Profile>,
793+
force_non_host: bool,
785794
verbose: bool,
786795
) -> Result<(UpdateStatus, Toolchain<'_>)> {
787796
common::warn_if_host_is_incompatible(
788797
toolchain,
789798
&TargetTriple::from_host_or_build(self.process),
790799
&toolchain.target,
791-
false,
800+
force_non_host,
792801
)?;
793802
if verbose {
794803
(self.notify_handler)(Notification::LookingForToolchain(toolchain));

0 commit comments

Comments
 (0)