@@ -58,42 +58,43 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
58
58
this.thir[scrutinee].span,
59
59
),
60
60
ExprKind::If { cond, then, else_opt, if_then_scope } => {
61
- let then_blk;
62
61
let then_span = this.thir[then].span;
63
62
let then_source_info = this.source_info(then_span);
64
63
let condition_scope = this.local_scope();
65
64
66
- let mut else_blk = unpack!(
67
- then_blk = this.in_scope(
68
- (if_then_scope, then_source_info),
69
- LintLevel::Inherited,
70
- |this| {
71
- let source_info = if this.is_let(cond) {
72
- let variable_scope =
73
- this.new_source_scope(then_span, LintLevel::Inherited, None);
74
- this.source_scope = variable_scope;
75
- SourceInfo { span: then_span, scope: variable_scope }
76
- } else {
77
- this.source_info(then_span)
78
- };
79
- let (then_block, else_block) =
80
- this.in_if_then_scope(condition_scope, then_span, |this| {
81
- let then_blk = unpack!(this.then_else_break(
82
- block,
83
- cond,
84
- Some(condition_scope), // Temp scope
85
- condition_scope,
86
- source_info,
87
- true, // Declare `let` bindings normally
88
- ));
89
-
90
- this.expr_into_dest(destination, then_blk, then)
91
- });
92
- then_block.and(else_block)
93
- },
94
- )
65
+ let then_and_else_blocks = this.in_scope(
66
+ (if_then_scope, then_source_info),
67
+ LintLevel::Inherited,
68
+ |this| {
69
+ let source_info = if this.is_let(cond) {
70
+ let variable_scope =
71
+ this.new_source_scope(then_span, LintLevel::Inherited, None);
72
+ this.source_scope = variable_scope;
73
+ SourceInfo { span: then_span, scope: variable_scope }
74
+ } else {
75
+ this.source_info(then_span)
76
+ };
77
+ let (then_block, else_block) =
78
+ this.in_if_then_scope(condition_scope, then_span, |this| {
79
+ let then_blk = unpack!(this.then_else_break(
80
+ block,
81
+ cond,
82
+ Some(condition_scope), // Temp scope
83
+ condition_scope,
84
+ source_info,
85
+ true, // Declare `let` bindings normally
86
+ ));
87
+
88
+ this.expr_into_dest(destination, then_blk, then)
89
+ });
90
+ then_block.and(else_block)
91
+ },
95
92
);
96
93
94
+ // Unpack `BlockAnd<BasicBlock>` into `(then_blk, else_blk)`.
95
+ let (then_blk, mut else_blk);
96
+ else_blk = unpack!(then_blk = then_and_else_blocks);
97
+
97
98
else_blk = if let Some(else_opt) = else_opt {
98
99
unpack!(this.expr_into_dest(destination, else_blk, else_opt))
99
100
} else {
0 commit comments