Skip to content

Commit 1bad5d1

Browse files
committed
Fix MIR unpretty on failure conditions
1 parent f6f050d commit 1bad5d1

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/librustc_driver/pretty.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -817,13 +817,12 @@ pub fn pretty_print_input(sess: Session,
817817
&id,
818818
resolve::MakeGlobMap::No,
819819
|tcx, mir_map, _, _| {
820-
let mir_map = mir_map.unwrap();
821-
822-
for (nodeid, mir) in &mir_map.map {
823-
try!(writeln!(out, "MIR for {}", tcx.map.node_to_string(*nodeid)));
824-
try!(write_mir_pretty(mir, &mut out));
820+
if let Some(mir_map) = mir_map {
821+
for (nodeid, mir) in &mir_map.map {
822+
try!(writeln!(out, "MIR for {}", tcx.map.node_to_string(*nodeid)));
823+
try!(write_mir_pretty(mir, &mut out));
824+
}
825825
}
826-
827826
Ok(())
828827
}), &sess)
829828
}
@@ -840,12 +839,14 @@ pub fn pretty_print_input(sess: Session,
840839
&id,
841840
resolve::MakeGlobMap::No,
842841
|tcx, mir_map, _, _| {
843-
let mir_map = mir_map.unwrap();
844-
try!(writeln!(out, "MIR for {}", tcx.map.node_to_string(nodeid)));
845-
let mir = mir_map.map.get(&nodeid).unwrap_or_else(|| {
846-
sess.fatal(&format!("no MIR map entry for node {}", nodeid))
847-
});
848-
write_mir_pretty(mir, &mut out)
842+
if let Some(mir_map) = mir_map {
843+
try!(writeln!(out, "MIR for {}", tcx.map.node_to_string(nodeid)));
844+
let mir = mir_map.map.get(&nodeid).unwrap_or_else(|| {
845+
sess.fatal(&format!("no MIR map entry for node {}", nodeid))
846+
});
847+
try!(write_mir_pretty(mir, &mut out));
848+
}
849+
Ok(())
849850
}), &sess)
850851
}
851852

0 commit comments

Comments
 (0)