Skip to content

Commit a33fd77

Browse files
committed
Unwrap DropTemps in higher::if_block
1 parent 3e598cf commit a33fd77

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

clippy_lints/src/utils/higher.rs

+5
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ pub fn for_loop(expr: &hir::Expr) -> Option<(&hir::Pat, &hir::Expr, &hir::Expr)>
203203
/// `if cond { then } else { els }` becomes `(cond, then, Some(els))`
204204
pub fn if_block(expr: &hir::Expr) -> Option<(&hir::Expr, &hir::Expr, Option<&hir::Expr>)> {
205205
if let hir::ExprKind::Match(ref cond, ref arms, hir::MatchSource::IfDesugar {..}) = expr.node {
206+
let cond = if let hir::ExprKind::DropTemps(ref cond) = cond.node {
207+
cond
208+
} else {
209+
panic!("If block desugar must contain DropTemps");
210+
};
206211
let then = &arms[0].body;
207212
let els = arms.get(1).map(|x| &*x.body);
208213
Some((cond, then, els))

0 commit comments

Comments
 (0)