Skip to content

Commit 49176ef

Browse files
committed
Show channel updates even if self update is not allowed
I don't think this complexity is worth it? Looking at the changes from when this indirection was introduced does not make it clearer.
1 parent 86a683a commit 49176ef

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

src/cli/common.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -291,24 +291,20 @@ pub(crate) async fn update_all_channels(
291291
info!("no updatable toolchains installed");
292292
}
293293

294-
let show_channel_updates = || {
295-
if !toolchains.is_empty() {
296-
writeln!(cfg.process.stdout().lock())?;
297-
298-
let t = toolchains
299-
.into_iter()
300-
.map(|(p, s)| (PackageUpdate::Toolchain(p), s))
301-
.collect();
302-
show_channel_updates(cfg, t)?;
303-
}
304-
Ok(())
305-
};
294+
if !toolchains.is_empty() {
295+
writeln!(cfg.process.stdout().lock())?;
296+
297+
let t = toolchains
298+
.into_iter()
299+
.map(|(p, s)| (PackageUpdate::Toolchain(p), s))
300+
.collect();
301+
show_channel_updates(cfg, t)?;
302+
}
306303

307304
if do_self_update {
308-
exit_code &= self_update(show_channel_updates, cfg.process).await?;
309-
} else {
310-
show_channel_updates()?;
305+
exit_code &= self_update(cfg.process).await?;
311306
}
307+
312308
Ok(exit_code)
313309
}
314310

@@ -350,10 +346,7 @@ pub(crate) fn self_update_permitted(explicit: bool) -> Result<SelfUpdatePermissi
350346
}
351347

352348
/// Performs all of a self-update: check policy, download, apply and exit.
353-
pub(crate) async fn self_update<F>(before_restart: F, process: &Process) -> Result<utils::ExitCode>
354-
where
355-
F: FnOnce() -> Result<()>,
356-
{
349+
pub(crate) async fn self_update(process: &Process) -> Result<utils::ExitCode> {
357350
match self_update_permitted(false)? {
358351
SelfUpdatePermission::HardFail => {
359352
error!("Unable to self-update. STOP");
@@ -366,8 +359,6 @@ where
366359

367360
let setup_path = self_update::prepare_update(process).await?;
368361

369-
before_restart()?;
370-
371362
if let Some(ref setup_path) = setup_path {
372363
return self_update::run_update(setup_path);
373364
} else {

src/cli/rustup_mode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ async fn update(
923923
}
924924
}
925925
if self_update {
926-
exit_code &= common::self_update(|| Ok(()), cfg.process).await?;
926+
exit_code &= common::self_update(cfg.process).await?;
927927
}
928928
} else if ensure_active_toolchain {
929929
let (toolchain, reason) = cfg.ensure_active_toolchain(force_non_host, true).await?;

0 commit comments

Comments
 (0)