Clarify how lowering if produces then/else blocks

This makes it easier to see that the call to `in_scope` returns both the then
block and the else block. The rather confusing `unpack!` step is confined to
its own separate line.

(This patch reindents several lines, so using "ignore whitespace" is
recommended in order to focus on the actual changes.)
This commit is contained in:
Zalathar 2024-03-06 14:56:13 +11:00
parent 62415e2a95
commit 7396fd1fa0

View File

@ -58,13 +58,11 @@ pub(crate) fn expr_into_dest(
this.thir[scrutinee].span,
),
ExprKind::If { cond, then, else_opt, if_then_scope } => {
let then_blk;
let then_span = this.thir[then].span;
let then_source_info = this.source_info(then_span);
let condition_scope = this.local_scope();
let mut else_blk = unpack!(
then_blk = this.in_scope(
let then_and_else_blocks = this.in_scope(
(if_then_scope, then_source_info),
LintLevel::Inherited,
|this| {
@ -91,9 +89,12 @@ pub(crate) fn expr_into_dest(
});
then_block.and(else_block)
},
)
);
// Unpack `BlockAnd<BasicBlock>` into `(then_blk, else_blk)`.
let (then_blk, mut else_blk);
else_blk = unpack!(then_blk = then_and_else_blocks);
else_blk = if let Some(else_opt) = else_opt {
unpack!(this.expr_into_dest(destination, else_blk, else_opt))
} else {