From 32e3338346e49cced6e35621eda11cbc6482bbe4 Mon Sep 17 00:00:00 2001 From: rami3l Date: Mon, 5 Aug 2024 11:17:38 +0800 Subject: [PATCH] refactor(common): use early return in `warn_if_host_is_incompatible()` --- src/cli/common.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cli/common.rs b/src/cli/common.rs index f342fd5abc..5d3a99a812 100644 --- a/src/cli/common.rs +++ b/src/cli/common.rs @@ -642,11 +642,12 @@ pub(crate) fn warn_if_host_is_incompatible( target_triple: &TargetTriple, force_non_host: bool, ) -> Result<()> { - if !force_non_host && !host_arch.can_run(target_triple)? { - error!("DEPRECATED: future versions of rustup will require --force-non-host to install a non-host toolchain."); - warn!("toolchain '{toolchain}' may not be able to run on this system."); - warn!("If you meant to build software to target that platform, perhaps try `rustup target add {target_triple}` instead?"); + if force_non_host || host_arch.can_run(target_triple)? { + return Ok(()); } + error!("DEPRECATED: future versions of rustup will require --force-non-host to install a non-host toolchain."); + warn!("toolchain '{toolchain}' may not be able to run on this system."); + warn!("If you meant to build software to target that platform, perhaps try `rustup target add {target_triple}` instead?"); Ok(()) }