diff options
| author | Cameron Steffen <cam.steffen94@gmail.com> | 2021-08-01 17:44:31 -0500 |
|---|---|---|
| committer | Cameron Steffen <cam.steffen94@gmail.com> | 2021-08-01 17:46:28 -0500 |
| commit | 02cd72e34b36d7bf2e27b9eaedf2af4e19cc2d85 (patch) | |
| tree | 4684f3dd1542211bfd22fd7407d6a8b73a5ee9f2 /compiler | |
| parent | 8746b79a384cdb30ecc2dae3ca0f0ece4dc56eed (diff) | |
| download | rust-02cd72e34b36d7bf2e27b9eaedf2af4e19cc2d85.tar.gz rust-02cd72e34b36d7bf2e27b9eaedf2af4e19cc2d85.zip | |
Inline make_if macro
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_ast_lowering/src/expr.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 7fecf537cfb..bacf5662bc0 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -442,18 +442,10 @@ impl<'hir> LoweringContext<'_, 'hir> { then: &Block, else_opt: Option<&Expr>, ) -> hir::ExprKind<'hir> { - macro_rules! make_if { - ($opt:expr) => {{ - let cond = self.lower_expr(cond); - let then_expr = self.lower_block_expr(then); - hir::ExprKind::If(cond, self.arena.alloc(then_expr), $opt) - }}; - } - if let Some(rslt) = else_opt { - make_if!(Some(self.lower_expr(rslt))) - } else { - make_if!(None) - } + let cond = self.lower_expr(cond); + let then = self.arena.alloc(self.lower_block_expr(then)); + let els = else_opt.map(|els| self.lower_expr(els)); + hir::ExprKind::If(cond, then, els) } fn lower_expr_if_let( |
