@@ -12,20 +12,25 @@ use super::{internal, run};
12
12
pub fn write_smir_pretty < ' tcx > ( tcx : TyCtxt < ' tcx > , w : & mut dyn io:: Write ) -> io:: Result < ( ) > {
13
13
writeln ! ( w, "// WARNING: This is highly experimental output it's intended for stable-mir developers only." ) . unwrap ( ) ;
14
14
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
+
15
16
run ( tcx, || {
16
17
let items = stable_mir:: all_local_items ( ) ;
17
- items. iter ( ) . for_each ( |item| {
18
+ let _ = items. iter ( ) . map ( |item| -> io :: Result < ( ) > {
18
19
// 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 < _ > > ( ) ;
26
28
writeln ! ( w, " }}" ) . unwrap ( ) ;
27
- } )
28
- } )
29
+ Ok ( ( ) )
30
+ } ) . collect :: < Vec < _ > > ( ) ;
31
+ Ok ( ( ) )
32
+ } ) . collect :: < Vec < _ > > ( ) ;
33
+
29
34
} ) ;
30
35
Ok ( ( ) )
31
36
}
0 commit comments