Skip to content

Commit

Permalink
Unwrap DropTemps in higher::if_block
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed May 11, 2019
1 parent 3e598cf commit a33fd77
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clippy_lints/src/utils/higher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ pub fn for_loop(expr: &hir::Expr) -> Option<(&hir::Pat, &hir::Expr, &hir::Expr)>
/// `if cond { then } else { els }` becomes `(cond, then, Some(els))`
pub fn if_block(expr: &hir::Expr) -> Option<(&hir::Expr, &hir::Expr, Option<&hir::Expr>)> {
if let hir::ExprKind::Match(ref cond, ref arms, hir::MatchSource::IfDesugar {..}) = expr.node {
let cond = if let hir::ExprKind::DropTemps(ref cond) = cond.node {
cond
} else {
panic!("If block desugar must contain DropTemps");
};
let then = &arms[0].body;
let els = arms.get(1).map(|x| &*x.body);
Some((cond, then, els))
Expand Down

0 comments on commit a33fd77

Please sign in to comment.