Skip to content

Commit

Permalink
Clippy: Match on assert!() expansions without an inner block.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Nov 19, 2020
1 parent 454eaec commit a125ef2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/tools/clippy/clippy_lints/src/assertions_on_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,11 @@ fn match_assert_with_message<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>)
if let ExprKind::Block(ref block, _) = arms[0].body.kind;
if block.stmts.is_empty();
if let Some(block_expr) = &block.expr;
if let ExprKind::Block(ref inner_block, _) = block_expr.kind;
if let Some(begin_panic_call) = &inner_block.expr;
// inner block is optional. unwarp it if it exists, or use the expression as is otherwise.
if let Some(begin_panic_call) = match block_expr.kind {
ExprKind::Block(ref inner_block, _) => &inner_block.expr,
_ => &block.expr,
};
// function call
if let Some(args) = match_panic_call(cx, begin_panic_call);
if args.len() == 1;
Expand Down

0 comments on commit a125ef2

Please sign in to comment.