The ordinary lowering of thir::ExprKind::Let
is unreachable
After desugaring, `let` expressions should only appear inside `if` expressions or `match` guards, possibly nested within a let-chain. In both cases they are specifically handled by the lowerings of those expressions, so this case is currently unreachable.
This commit is contained in:
parent
4cdd20584c
commit
972d8daf47
@ -109,38 +109,12 @@ pub(crate) fn expr_into_dest(
|
|||||||
this.cfg.goto(else_blk, source_info, join_block);
|
this.cfg.goto(else_blk, source_info, join_block);
|
||||||
join_block.unit()
|
join_block.unit()
|
||||||
}
|
}
|
||||||
ExprKind::Let { expr, ref pat } => {
|
ExprKind::Let { .. } => {
|
||||||
let scope = this.local_scope();
|
// After desugaring, `let` expressions should only appear inside `if`
|
||||||
let (true_block, false_block) = this.in_if_then_scope(scope, expr_span, |this| {
|
// expressions or `match` guards, possibly nested within a let-chain.
|
||||||
this.lower_let_expr(block, expr, pat, scope, None, expr_span, true)
|
// In both cases they are specifically handled by the lowerings of
|
||||||
});
|
// those expressions, so this case is currently unreachable.
|
||||||
|
span_bug!(expr_span, "unexpected let expression outside of if or match-guard");
|
||||||
this.cfg.push_assign_constant(
|
|
||||||
true_block,
|
|
||||||
source_info,
|
|
||||||
destination,
|
|
||||||
ConstOperand {
|
|
||||||
span: expr_span,
|
|
||||||
user_ty: None,
|
|
||||||
const_: Const::from_bool(this.tcx, true),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
this.cfg.push_assign_constant(
|
|
||||||
false_block,
|
|
||||||
source_info,
|
|
||||||
destination,
|
|
||||||
ConstOperand {
|
|
||||||
span: expr_span,
|
|
||||||
user_ty: None,
|
|
||||||
const_: Const::from_bool(this.tcx, false),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
let join_block = this.cfg.start_new_block();
|
|
||||||
this.cfg.goto(true_block, source_info, join_block);
|
|
||||||
this.cfg.goto(false_block, source_info, join_block);
|
|
||||||
join_block.unit()
|
|
||||||
}
|
}
|
||||||
ExprKind::NeverToAny { source } => {
|
ExprKind::NeverToAny { source } => {
|
||||||
let source_expr = &this.thir[source];
|
let source_expr = &this.thir[source];
|
||||||
|
Loading…
Reference in New Issue
Block a user