Skip to content

Commit a796e7a

Browse files
committed
fix(utils): make ExitCode #[must_use]
1 parent 3fa1790 commit a796e7a

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/cli/rustup_mode.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ async fn update(cfg: &mut Cfg<'_>, opts: UpdateOpts) -> Result<utils::ExitCode>
864864
}
865865
}
866866
if self_update {
867-
common::self_update(|| Ok(()), cfg.process).await?;
867+
exit_code &= common::self_update(|| Ok(()), cfg.process).await?;
868868
}
869869
} else {
870870
exit_code &= common::update_all_channels(cfg, self_update, opts.force).await?;
@@ -1205,8 +1205,7 @@ async fn component_list(
12051205
installed_only,
12061206
quiet,
12071207
cfg.process,
1208-
)?;
1209-
Ok(utils::ExitCode(0))
1208+
)
12101209
}
12111210

12121211
async fn component_add(

src/cli/self_update.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,9 @@ pub(crate) async fn install(
496496
mut opts: InstallOpts<'_>,
497497
process: &Process,
498498
) -> Result<utils::ExitCode> {
499+
#[cfg_attr(windows, allow(unused_mut))]
500+
let mut exit_code = utils::ExitCode(0);
501+
499502
opts.validate(process).map_err(|e| {
500503
anyhow!(
501504
"Pre-checks for host and toolchain failed: {e}\n\
@@ -513,7 +516,9 @@ pub(crate) async fn install(
513516
}
514517

515518
#[cfg(unix)]
516-
unix::do_anti_sudo_check(no_prompt, process)?;
519+
{
520+
exit_code &= unix::do_anti_sudo_check(no_prompt, process)?;
521+
}
517522

518523
let mut term = process.stdout().terminal(process);
519524

@@ -590,7 +595,7 @@ pub(crate) async fn install(
590595
windows::ensure_prompt(process)?;
591596
}
592597

593-
Ok(utils::ExitCode(0))
598+
Ok(exit_code)
594599
}
595600

596601
fn rustc_or_cargo_exists_in_path(process: &Process) -> Result<()> {

src/cli/setup_mode.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ pub async fn main(
108108
}
109109

110110
if dump_testament {
111-
common::dump_testament(process)?;
112-
return Ok(utils::ExitCode(0));
111+
return common::dump_testament(process);
113112
}
114113

115114
if profile == Profile::Complete {

src/utils/utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub(crate) use crate::utils::utils::raw::is_directory;
2222

2323
pub use crate::utils::utils::raw::{is_file, path_exists};
2424

25+
#[must_use]
2526
#[derive(Debug, PartialEq, Eq)]
2627
pub struct ExitCode(pub i32);
2728

0 commit comments

Comments
 (0)