Skip to content

Commit f55fba1

Browse files
committed
Remove intermediate state from error handling
1 parent 0f27d6e commit f55fba1

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/dist/mod.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,23 +1043,17 @@ async fn try_update_from_dist_(
10431043
download.process,
10441044
)
10451045
.await;
1046+
10461047
// inspect, determine what context to add, then process afterwards.
1047-
let mut download_not_exists = false;
1048-
match &result {
1049-
Ok(_) => (),
1050-
Err(e) => {
1051-
if let Some(RustupError::DownloadNotExists { .. }) = e.downcast_ref::<RustupError>() {
1052-
download_not_exists = true
1053-
}
1048+
if let Err(e) = &result {
1049+
if let Some(RustupError::DownloadNotExists { .. }) = e.downcast_ref::<RustupError>() {
1050+
return result.with_context(|| {
1051+
format!("could not download nonexistent rust version `{toolchain_str}`")
1052+
});
10541053
}
10551054
}
1056-
if download_not_exists {
1057-
result.with_context(|| {
1058-
format!("could not download nonexistent rust version `{toolchain_str}`")
1059-
})
1060-
} else {
1061-
result
1062-
}
1055+
1056+
result
10631057
}
10641058

10651059
pub(crate) async fn dl_v2_manifest(

0 commit comments

Comments
 (0)