Skip to content

Commit 7bb78f2

Browse files
committed
change smir to StableMir
1 parent 8175098 commit 7bb78f2

File tree

3 files changed

+35
-23
lines changed

3 files changed

+35
-23
lines changed

compiler/rustc_driver_impl/src/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
326326
write_mir_graphviz(ex.tcx(), None, &mut out).unwrap();
327327
String::from_utf8(out).unwrap()
328328
}
329-
Smir => {
329+
StableMir => {
330330
let mut out = Vec::new();
331331
write_smir_pretty(ex.tcx(), &mut out).unwrap();
332332
String::from_utf8(out).unwrap()

compiler/rustc_session/src/config.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -2926,13 +2926,13 @@ fn parse_pretty(handler: &EarlyErrorHandler, unstable_opts: &UnstableOptions) ->
29262926
"thir-tree" => ThirTree,
29272927
"thir-flat" => ThirFlat,
29282928
"mir" => Mir,
2929-
"smir" => Smir,
2929+
"stable-mir" => StableMir,
29302930
"mir-cfg" => MirCFG,
29312931
name => handler.early_error(format!(
29322932
"argument to `unpretty` must be one of `normal`, `identified`, \
29332933
`expanded`, `expanded,identified`, `expanded,hygiene`, \
29342934
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
2935-
`hir,typed`, `hir-tree`, `thir-tree`, `thir-flat`, `mir` or \
2935+
`hir,typed`, `hir-tree`, `thir-tree`, `thir-flat`, `mir`, `stable-mir`, or \
29362936
`mir-cfg`; got {name}"
29372937
)),
29382938
};
@@ -3107,8 +3107,8 @@ pub enum PpMode {
31073107
Mir,
31083108
/// `-Zunpretty=mir-cfg`
31093109
MirCFG,
3110-
/// `-Zunpretty=smir`
3111-
Smir,
3110+
/// `-Zunpretty=stable-mir`
3111+
StableMir,
31123112
}
31133113

31143114
impl PpMode {
@@ -3126,21 +3126,21 @@ impl PpMode {
31263126
| ThirFlat
31273127
| Mir
31283128
| MirCFG
3129-
| Smir => true,
3129+
| StableMir => true,
31303130
}
31313131
}
31323132
pub fn needs_hir(&self) -> bool {
31333133
use PpMode::*;
31343134
match *self {
31353135
Source(_) | AstTree | AstTreeExpanded => false,
31363136

3137-
Hir(_) | HirTree | ThirTree | ThirFlat | Mir | MirCFG | Smir => true,
3137+
Hir(_) | HirTree | ThirTree | ThirFlat | Mir | MirCFG | StableMir => true,
31383138
}
31393139
}
31403140

31413141
pub fn needs_analysis(&self) -> bool {
31423142
use PpMode::*;
3143-
matches!(*self, Hir(PpHirMode::Typed) | Mir | Smir | MirCFG | ThirTree | ThirFlat)
3143+
matches!(*self, Hir(PpHirMode::Typed) | Mir | StableMir | MirCFG | ThirTree | ThirFlat)
31443144
}
31453145
}
31463146

compiler/rustc_smir/src/rustc_internal/pretty.rs

+27-15
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,34 @@ pub fn write_smir_pretty<'tcx>(tcx: TyCtxt<'tcx>, w: &mut dyn io::Write) -> io::
1515

1616
run(tcx, || {
1717
let items = stable_mir::all_local_items();
18-
let _ = items.iter().map(|item| -> io::Result<()> {
19-
// Because we can't return a Result from a closure, we have to unwrap here.
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<_>>();
28-
writeln!(w, " }}").unwrap();
18+
let _ = items
19+
.iter()
20+
.map(|item| -> io::Result<()> {
21+
// Because we can't return a Result from a closure, we have to unwrap here.
22+
writeln!(w, "{}", function_name(*item, tcx))?;
23+
writeln!(w, "{}", function_body(*item, tcx))?;
24+
let _ = item
25+
.body()
26+
.blocks
27+
.iter()
28+
.enumerate()
29+
.map(|(index, block)| -> io::Result<()> {
30+
writeln!(w, " bb{}: {{", index)?;
31+
let _ = block
32+
.statements
33+
.iter()
34+
.map(|statement| -> io::Result<()> {
35+
writeln!(w, "{}", pretty_statement(&statement.kind, tcx))?;
36+
Ok(())
37+
})
38+
.collect::<Vec<_>>();
39+
writeln!(w, " }}").unwrap();
40+
Ok(())
41+
})
42+
.collect::<Vec<_>>();
2943
Ok(())
30-
}).collect::<Vec<_>>();
31-
Ok(())
32-
}).collect::<Vec<_>>();
33-
44+
})
45+
.collect::<Vec<_>>();
3446
});
3547
Ok(())
3648
}

0 commit comments

Comments
 (0)