Skip to content

Commit 07539b8

Browse files
committed
let-else: use DropTemps to fix borrowck complaints
This prevents *any* unreachable_code warnings on DropTemps, including from its other uses.
1 parent 14283b2 commit 07539b8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

compiler/rustc_ast_lowering/src/block.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
159159
span,
160160
kind: hir::ExprKind::If(let_expr, then_expr, Some(else_expr)),
161161
});
162+
let drop_temps = self.expr_drop_temps(span, if_expr, AttrVec::new());
162163
if !self.sess.features_untracked().let_else {
163164
feature_err(
164165
&self.sess.parse_sess,
@@ -168,6 +169,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
168169
)
169170
.emit();
170171
}
171-
if_expr
172+
drop_temps
172173
}
173174
}

compiler/rustc_typeck/src/check/expr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
225225
| ExprKind::If(..)
226226
| ExprKind::Let(..)
227227
| ExprKind::Loop(..)
228+
| ExprKind::DropTemps(..)
228229
| ExprKind::Match(..) => {}
229230
// If `expr` is a result of desugaring the try block and is an ok-wrapped
230231
// diverging expression (e.g. it arose from desugaring of `try { return }`),

0 commit comments

Comments
 (0)