Skip to content

Commit 8175098

Browse files
committed
remove unwrap
1 parent 8a50f16 commit 8175098

File tree

1 file changed

+15
-10
lines changed
  • compiler/rustc_smir/src/rustc_internal

1 file changed

+15
-10
lines changed

compiler/rustc_smir/src/rustc_internal/pretty.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,25 @@ use super::{internal, run};
1212
pub fn write_smir_pretty<'tcx>(tcx: TyCtxt<'tcx>, w: &mut dyn io::Write) -> io::Result<()> {
1313
writeln!(w, "// WARNING: This is highly experimental output it's intended for stable-mir developers only.").unwrap();
1414
writeln!(w, "// If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir.").unwrap();
15+
1516
run(tcx, || {
1617
let items = stable_mir::all_local_items();
17-
items.iter().for_each(|item| {
18+
let _ = items.iter().map(|item| -> io::Result<()> {
1819
// Because we can't return a Result from a closure, we have to unwrap here.
19-
writeln!(w, "{}", function_name(*item, tcx)).unwrap();
20-
writeln!(w, "{}", function_body(*item, tcx)).unwrap();
21-
item.body().blocks.iter().enumerate().for_each(|(index, block)| {
22-
writeln!(w, " bb{}: {{", index).unwrap();
23-
block.statements.iter().for_each(|statement| {
24-
writeln!(w, "{}", pretty_statement(&statement.kind, tcx)).unwrap();
25-
});
20+
writeln!(w, "{}", function_name(*item, tcx))?;
21+
writeln!(w, "{}", function_body(*item, tcx))?;
22+
let _ = item.body().blocks.iter().enumerate().map(|(index, block)| -> io::Result<()> {
23+
writeln!(w, " bb{}: {{", index)?;
24+
let _ = block.statements.iter().map(|statement| -> io::Result<()> {
25+
writeln!(w, "{}", pretty_statement(&statement.kind, tcx))?;
26+
Ok(())
27+
}).collect::<Vec<_>>();
2628
writeln!(w, " }}").unwrap();
27-
})
28-
})
29+
Ok(())
30+
}).collect::<Vec<_>>();
31+
Ok(())
32+
}).collect::<Vec<_>>();
33+
2934
});
3035
Ok(())
3136
}

0 commit comments

Comments
 (0)