Skip to content

Commit a0e0b7b

Browse files
djcrami3l
authored andcommitted
Avoid swallowing errors in show()
1 parent 4011ef0 commit a0e0b7b

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

src/cli/rustup_mode.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,28 +1016,20 @@ async fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<utils::ExitCode> {
10161016
.map(|atar| (&atar.0, &atar.1))
10171017
.unzip();
10181018

1019-
let active_toolchain_targets: Vec<TargetTriple> = active_toolchain_name
1020-
.and_then(|atn| match atn {
1021-
ToolchainName::Official(desc) => DistributableToolchain::new(cfg, desc.clone())
1022-
.ok()
1023-
.and_then(|distributable| distributable.components().ok())
1024-
.map(|cs_vec| {
1025-
cs_vec
1026-
.into_iter()
1027-
.filter(|c| {
1028-
c.installed && c.component.short_name_in_manifest() == "rust-std"
1029-
})
1030-
.map(|c| c.component.target.expect("rust-std should have a target"))
1031-
.collect()
1032-
}),
1033-
ToolchainName::Custom(name) => {
1034-
Toolchain::new(cfg, LocalToolchainName::Named(name.into()))
1035-
.ok()?
1036-
.installed_targets()
1037-
.ok()
1038-
}
1039-
})
1040-
.unwrap_or_default();
1019+
let active_toolchain_targets = match active_toolchain_name {
1020+
Some(ToolchainName::Official(desc)) => DistributableToolchain::new(cfg, desc.clone())?
1021+
.components()?
1022+
.into_iter()
1023+
.filter_map(|c| {
1024+
(c.installed && c.component.short_name_in_manifest() == "rust-std")
1025+
.then(|| c.component.target.expect("rust-std should have a target"))
1026+
})
1027+
.collect(),
1028+
Some(ToolchainName::Custom(name)) => {
1029+
Toolchain::new(cfg, LocalToolchainName::Named(name.into()))?.installed_targets()?
1030+
}
1031+
None => Vec::new(),
1032+
};
10411033

10421034
// show installed toolchains
10431035
{

0 commit comments

Comments
 (0)