summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_mir_build/src/thir/print.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_mir_build/src/thir/print.rs')
-rw-r--r--compiler/rustc_mir_build/src/thir/print.rs36
1 files changed, 14 insertions, 22 deletions
diff --git a/compiler/rustc_mir_build/src/thir/print.rs b/compiler/rustc_mir_build/src/thir/print.rs
index c3b2309b7..28be31399 100644
--- a/compiler/rustc_mir_build/src/thir/print.rs
+++ b/compiler/rustc_mir_build/src/thir/print.rs
@@ -31,8 +31,8 @@ const INDENT: &str = " ";
macro_rules! print_indented {
($writer:ident, $s:expr, $indent_lvl:expr) => {
- let indent = (0..$indent_lvl).map(|_| INDENT).collect::<Vec<_>>().concat();
- writeln!($writer, "{}{}", indent, $s).expect("unable to write to ThirPrinter");
+ $writer.indent($indent_lvl);
+ writeln!($writer, "{}", $s).expect("unable to write to ThirPrinter");
};
}
@@ -48,6 +48,12 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
Self { thir, fmt: String::new() }
}
+ fn indent(&mut self, level: usize) {
+ for _ in 0..level {
+ self.fmt.push_str(INDENT);
+ }
+ }
+
fn print(&mut self) {
print_indented!(self, "params: [", 0);
for param in self.thir.params.iter() {
@@ -85,23 +91,11 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
}
fn print_block(&mut self, block_id: BlockId, depth_lvl: usize) {
- let Block {
- targeted_by_break,
- opt_destruction_scope,
- span,
- region_scope,
- stmts,
- expr,
- safety_mode,
- } = &self.thir.blocks[block_id];
+ let Block { targeted_by_break, span, region_scope, stmts, expr, safety_mode } =
+ &self.thir.blocks[block_id];
print_indented!(self, "Block {", depth_lvl);
print_indented!(self, format!("targeted_by_break: {}", targeted_by_break), depth_lvl + 1);
- print_indented!(
- self,
- format!("opt_destruction_scope: {:?}", opt_destruction_scope),
- depth_lvl + 1
- );
print_indented!(self, format!("span: {:?}", span), depth_lvl + 1);
print_indented!(self, format!("region_scope: {:?}", region_scope), depth_lvl + 1);
print_indented!(self, format!("safety_mode: {:?}", safety_mode), depth_lvl + 1);
@@ -127,14 +121,9 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
}
fn print_stmt(&mut self, stmt_id: StmtId, depth_lvl: usize) {
- let Stmt { kind, opt_destruction_scope } = &self.thir.stmts[stmt_id];
+ let Stmt { kind } = &self.thir.stmts[stmt_id];
print_indented!(self, "Stmt {", depth_lvl);
- print_indented!(
- self,
- format!("opt_destruction_scope: {:?}", opt_destruction_scope),
- depth_lvl + 1
- );
match kind {
StmtKind::Expr { scope, expr } => {
@@ -636,6 +625,9 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
PatKind::Wild => {
print_indented!(self, "Wild", depth_lvl + 1);
}
+ PatKind::Never => {
+ print_indented!(self, "Never", depth_lvl + 1);
+ }
PatKind::AscribeUserType { ascription, subpattern } => {
print_indented!(self, "AscribeUserType: {", depth_lvl + 1);
print_indented!(self, format!("ascription: {:?}", ascription), depth_lvl + 2);