@@ -66,6 +66,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
66
66
(if_then_scope, then_source_info),
67
67
LintLevel::Inherited,
68
68
|this| {
69
+ // FIXME: Does this need extra logic to handle let-chains?
69
70
let source_info = if this.is_let(cond) {
70
71
let variable_scope =
71
72
this.new_source_scope(then_span, LintLevel::Inherited, None);
@@ -74,6 +75,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
74
75
} else {
75
76
this.source_info(then_span)
76
77
};
78
+
79
+ // Lower the condition, and have it branch into `then` and `else` blocks.
77
80
let (then_block, else_block) =
78
81
this.in_if_then_scope(condition_scope, then_span, |this| {
79
82
let then_blk = unpack!(this.then_else_break(
@@ -85,8 +88,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
85
88
true, // Declare `let` bindings normally
86
89
));
87
90
91
+ // Lower the `then` arm into its block.
88
92
this.expr_into_dest(destination, then_blk, then)
89
93
});
94
+
95
+ // Pack `(then_block, else_block)` into `BlockAnd<BasicBlock>`.
90
96
then_block.and(else_block)
91
97
},
92
98
);
@@ -105,6 +111,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
105
111
this.cfg.push_assign_unit(else_blk, correct_si, destination, this.tcx);
106
112
}
107
113
114
+ // The `then` and `else` arms have been lowered into their respective
115
+ // blocks, so make both of them meet up in a new block.
108
116
let join_block = this.cfg.start_new_block();
109
117
this.cfg.goto(then_blk, source_info, join_block);
110
118
this.cfg.goto(else_blk, source_info, join_block);
0 commit comments