(if_then_scope, then_source_info),
LintLevel::Inherited,
|this| {
+ let source_info = if this.is_let(cond) {
+ let variable_scope = this.new_source_scope(
+ then_expr.span,
+ LintLevel::Inherited,
+ None,
+ );
+ this.source_scope = variable_scope;
+ SourceInfo { span: then_expr.span, scope: variable_scope }
+ } else {
+ this.source_info(then_expr.span)
+ };
let (then_block, else_block) =
this.in_if_then_scope(condition_scope, |this| {
let then_blk = unpack!(this.then_else_break(
&this.thir[cond],
Some(condition_scope),
condition_scope,
- then_expr.span,
+ source_info
));
+
this.expr_into_dest(destination, then_blk, then_expr)
});
then_block.and(else_block)
ExprKind::Let { expr, ref pat } => {
let scope = this.local_scope();
let (true_block, false_block) = this.in_if_then_scope(scope, |this| {
- this.lower_let_expr(block, &this.thir[expr], pat, scope, expr_span)
+ this.lower_let_expr(block, &this.thir[expr], pat, scope, None, expr_span)
});
this.cfg.push_assign_constant(
block_and
}
+
+ fn is_let(&self, expr: ExprId) -> bool {
+ match self.thir[expr].kind {
+ ExprKind::Let { .. } => true,
+ ExprKind::Scope { value, .. } => self.is_let(value),
+ _ => false,
+ }
+ }
}