Skip to content

Commit d300e4f

Browse files
committed
Auto merge of #31915 - nagisa:mir-unpretty-fix, r=arielb1
Fixes #31913
2 parents c5237b0 + eb69076 commit d300e4f

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-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

src/test/compile-fail/mir-unpretty.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags: -Z unstable-options --unpretty=mir
12+
13+
fn main() {
14+
let x: () = 0; //~ ERROR: mismatched types
15+
}

0 commit comments

Comments
 (0)