Skip to content

Commit caac0b9

Browse files
committed
reformat mir text pretty printer
1 parent 9d00dee commit caac0b9

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

src/librustc_mir/pretty.rs

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,33 @@ use syntax::ast::NodeId;
1616
const INDENT: &'static str = " ";
1717

1818
/// Write out a human-readable textual representation for the given MIR.
19-
pub fn write_mir_pretty<'a, 't, W, I>(tcx: &ty::TyCtxt<'t>, iter: I, w: &mut W) -> io::Result<()>
20-
where W: Write, I: Iterator<Item=(&'a NodeId, &'a Mir<'a>)> {
21-
for (&nodeid, mir) in iter {
22-
write_mir_intro(tcx, nodeid, mir, w)?;
23-
// Nodes
24-
for block in mir.all_basic_blocks() {
25-
write_basic_block(block, mir, w)?;
26-
}
27-
writeln!(w, "}}")?
19+
pub fn write_mir_pretty<'a, 'tcx, I>(tcx: &ty::TyCtxt<'tcx>,
20+
iter: I,
21+
w: &mut Write)
22+
-> io::Result<()>
23+
where I: Iterator<Item=(&'a NodeId, &'a Mir<'tcx>)>, 'tcx: 'a
24+
{
25+
for (&node_id, mir) in iter {
26+
write_mir_fn(tcx, node_id, mir, w)?;
27+
}
28+
Ok(())
29+
}
30+
31+
pub fn write_mir_fn<'tcx>(tcx: &ty::TyCtxt<'tcx>,
32+
node_id: NodeId,
33+
mir: &Mir<'tcx>,
34+
w: &mut Write)
35+
-> io::Result<()> {
36+
write_mir_intro(tcx, node_id, mir, w)?;
37+
for block in mir.all_basic_blocks() {
38+
write_basic_block(block, mir, w)?;
2839
}
40+
writeln!(w, "}}")?;
2941
Ok(())
3042
}
3143

3244
/// Write out a human-readable textual representation for the given basic block.
33-
fn write_basic_block<W: Write>(block: BasicBlock, mir: &Mir, w: &mut W) -> io::Result<()> {
45+
fn write_basic_block(block: BasicBlock, mir: &Mir, w: &mut Write) -> io::Result<()> {
3446
let data = mir.basic_block_data(block);
3547

3648
// Basic block label at the top.
@@ -49,9 +61,8 @@ fn write_basic_block<W: Write>(block: BasicBlock, mir: &Mir, w: &mut W) -> io::R
4961

5062
/// Write out a human-readable textual representation of the MIR's `fn` type and the types of its
5163
/// local variables (both user-defined bindings and compiler temporaries).
52-
fn write_mir_intro<W: Write>(tcx: &ty::TyCtxt, nid: NodeId, mir: &Mir, w: &mut W)
53-
-> io::Result<()> {
54-
64+
fn write_mir_intro(tcx: &ty::TyCtxt, nid: NodeId, mir: &Mir, w: &mut Write)
65+
-> io::Result<()> {
5566
write!(w, "fn {}(", tcx.map.path_to_string(nid))?;
5667

5768
// fn argument types.

0 commit comments

Comments
 (0)