Skip to content

Commit 05b37ff

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

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ pub(crate) async fn install(
496496
mut opts: InstallOpts<'_>,
497497
process: &Process,
498498
) -> Result<utils::ExitCode> {
499+
let mut exit_code = utils::ExitCode(0);
500+
499501
opts.validate(process).map_err(|e| {
500502
anyhow!(
501503
"Pre-checks for host and toolchain failed: {e}\n\
@@ -513,7 +515,9 @@ pub(crate) async fn install(
513515
}
514516

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

518522
let mut term = process.stdout().terminal(process);
519523

@@ -590,7 +594,7 @@ pub(crate) async fn install(
590594
windows::ensure_prompt(process)?;
591595
}
592596

593-
Ok(utils::ExitCode(0))
597+
Ok(exit_code)
594598
}
595599

596600
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)