Skip to content

Commit 354c17d

Browse files
committed
fixup! refactor(rustup-mode): extract warn_if_host_is_incompatible()
1 parent 0e3dfb5 commit 354c17d

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/cli/common.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -638,18 +638,15 @@ pub(crate) fn ignorable_error(
638638
/// Warns if rustup is trying to install a toolchain that might not be
639639
/// able to run on the host system.
640640
pub(crate) fn warn_if_host_is_incompatible(
641-
process: &Process,
642-
name: &PartialToolchainDesc,
641+
toolchain: impl Display,
642+
host_arch: &TargetTriple,
643+
target_triple: &TargetTriple,
643644
force_non_host: bool,
644645
) -> Result<()> {
645-
if name.has_triple() {
646-
let host_arch = TargetTriple::from_host_or_build(process);
647-
let target_triple = name.clone().resolve(&host_arch)?.target;
648-
if !force_non_host && !host_arch.can_run(&target_triple)? {
649-
error!("DEPRECATED: future versions of rustup will require --force-non-host to install a non-host toolchain.");
650-
warn!("toolchain '{name}' may not be able to run on this system.");
651-
warn!("If you meant to build software to target that platform, perhaps try `rustup target add {target_triple}` instead?");
652-
}
646+
if !force_non_host && !host_arch.can_run(&target_triple)? {
647+
error!("DEPRECATED: future versions of rustup will require --force-non-host to install a non-host toolchain.");
648+
warn!("toolchain '{toolchain}' may not be able to run on this system.");
649+
warn!("If you meant to build software to target that platform, perhaps try `rustup target add {target_triple}` instead?");
653650
}
654651
Ok(())
655652
}

src/cli/rustup_mode.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,11 @@ async fn update(cfg: &mut Cfg<'_>, opts: UpdateOpts) -> Result<utils::ExitCode>
815815
if !names.is_empty() {
816816
for name in names {
817817
// This needs another pass to fix it all up
818-
common::warn_if_host_is_incompatible(cfg.process, &name, forced)?;
818+
if name.has_triple() {
819+
let host_arch = TargetTriple::from_host_or_build(cfg.process);
820+
let target_triple = name.clone().resolve(&host_arch)?.target;
821+
common::warn_if_host_is_incompatible(&name, &host_arch, &target_triple, forced)?;
822+
}
819823
let desc = name.resolve(&cfg.get_default_host_triple()?)?;
820824

821825
let components = opts.component.iter().map(|s| &**s).collect::<Vec<_>>();

0 commit comments

Comments
 (0)