Skip to content

Commit a125ef2

Browse files
committed
Clippy: Match on assert!() expansions without an inner block.
1 parent 454eaec commit a125ef2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/tools/clippy/clippy_lints/src/assertions_on_constants.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,11 @@ fn match_assert_with_message<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>)
129129
if let ExprKind::Block(ref block, _) = arms[0].body.kind;
130130
if block.stmts.is_empty();
131131
if let Some(block_expr) = &block.expr;
132-
if let ExprKind::Block(ref inner_block, _) = block_expr.kind;
133-
if let Some(begin_panic_call) = &inner_block.expr;
132+
// inner block is optional. unwarp it if it exists, or use the expression as is otherwise.
133+
if let Some(begin_panic_call) = match block_expr.kind {
134+
ExprKind::Block(ref inner_block, _) => &inner_block.expr,
135+
_ => &block.expr,
136+
};
134137
// function call
135138
if let Some(args) = match_panic_call(cx, begin_panic_call);
136139
if args.len() == 1;

0 commit comments

Comments
 (0)