diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-25 19:12:15 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-26 06:35:44 +1000 |
| commit | 7ac2d1f1bdb2348b13eb4f5fb9c7d620e316034f (patch) | |
| tree | 310683cb906ab06430be2656138ac6e3cfd4a22f /compiler/rustc_ast_pretty | |
| parent | e37c3674828a75ffdc2b94d9d273e9c02a9ee11f (diff) | |
| download | rust-7ac2d1f1bdb2348b13eb4f5fb9c7d620e316034f.tar.gz rust-7ac2d1f1bdb2348b13eb4f5fb9c7d620e316034f.zip | |
Improve HIR pretty-printing of if/else some more.
In the AST the "then" block is represented as a `Block`. In HIR the "then" block is represented as an `Expr` that happens to always be. `ExprKind::Block`. By deconstructing the `ExprKind::Block` to extract the block within, things print properly. For `issue-82392.rs`, note that we no longer print a type after the "then" block. This is good, it now matches how we don't print a type for the "else" block. (Well, we do print a type after the "else" block, but it's for the whole if/else.) Also tighten up some of the pattern matching -- these block expressions within if/else will never have labels.
Diffstat (limited to 'compiler/rustc_ast_pretty')
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state/expr.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index f2a9a688d8b..9546ffafb19 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -30,7 +30,7 @@ impl<'a> State<'a> { self.print_else(e.as_deref()) } // Final `else` block. - ast::ExprKind::Block(b, _) => { + ast::ExprKind::Block(b, None) => { self.cbox(0); self.ibox(0); self.word(" else "); |
