Skip to content

Commit

Permalink
let-else: use DropTemps to fix borrowck complaints
Browse files Browse the repository at this point in the history
This prevents *any* unreachable_code warnings on
DropTemps, including from its other uses.
  • Loading branch information
cormacrelf committed Feb 16, 2022
1 parent 14283b2 commit 07539b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/rustc_ast_lowering/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
span,
kind: hir::ExprKind::If(let_expr, then_expr, Some(else_expr)),
});
let drop_temps = self.expr_drop_temps(span, if_expr, AttrVec::new());
if !self.sess.features_untracked().let_else {
feature_err(
&self.sess.parse_sess,
Expand All @@ -168,6 +169,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
)
.emit();
}
if_expr
drop_temps
}
}
1 change: 1 addition & 0 deletions compiler/rustc_typeck/src/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
| ExprKind::If(..)
| ExprKind::Let(..)
| ExprKind::Loop(..)
| ExprKind::DropTemps(..)
| ExprKind::Match(..) => {}
// If `expr` is a result of desugaring the try block and is an ok-wrapped
// diverging expression (e.g. it arose from desugaring of `try { return }`),
Expand Down

0 comments on commit 07539b8

Please sign in to comment.