diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index a82176fb23..84fbd658d0 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -864,7 +864,7 @@ async fn update(cfg: &mut Cfg<'_>, opts: UpdateOpts) -> Result } } if self_update { - common::self_update(|| Ok(()), cfg.process).await?; + exit_code &= common::self_update(|| Ok(()), cfg.process).await?; } } else { exit_code &= common::update_all_channels(cfg, self_update, opts.force).await?; @@ -1205,8 +1205,7 @@ async fn component_list( installed_only, quiet, cfg.process, - )?; - Ok(utils::ExitCode(0)) + ) } async fn component_add( diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index 5b5ef77898..0d4e1341dd 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -496,6 +496,9 @@ pub(crate) async fn install( mut opts: InstallOpts<'_>, process: &Process, ) -> Result { + #[cfg_attr(not(unix), allow(unused_mut))] + let mut exit_code = utils::ExitCode(0); + opts.validate(process).map_err(|e| { anyhow!( "Pre-checks for host and toolchain failed: {e}\n\ @@ -513,7 +516,9 @@ pub(crate) async fn install( } #[cfg(unix)] - unix::do_anti_sudo_check(no_prompt, process)?; + { + exit_code &= unix::do_anti_sudo_check(no_prompt, process)?; + } let mut term = process.stdout().terminal(process); @@ -590,7 +595,7 @@ pub(crate) async fn install( windows::ensure_prompt(process)?; } - Ok(utils::ExitCode(0)) + Ok(exit_code) } fn rustc_or_cargo_exists_in_path(process: &Process) -> Result<()> { diff --git a/src/cli/setup_mode.rs b/src/cli/setup_mode.rs index 1df03d931b..ed2fe95c9d 100644 --- a/src/cli/setup_mode.rs +++ b/src/cli/setup_mode.rs @@ -108,8 +108,7 @@ pub async fn main( } if dump_testament { - common::dump_testament(process)?; - return Ok(utils::ExitCode(0)); + return common::dump_testament(process); } if profile == Profile::Complete { diff --git a/src/utils/utils.rs b/src/utils/utils.rs index 40855b35ab..67f6391947 100644 --- a/src/utils/utils.rs +++ b/src/utils/utils.rs @@ -22,6 +22,7 @@ pub(crate) use crate::utils::utils::raw::is_directory; pub use crate::utils::utils::raw::{is_file, path_exists}; +#[must_use] #[derive(Debug, PartialEq, Eq)] pub struct ExitCode(pub i32);