@@ -422,8 +422,28 @@ fn is_zero(expr: &Expr<'_>) -> bool {
422
422
423
423
fn check_custom_abs ( cx : & LateContext < ' _ , ' _ > , expr : & Expr < ' _ > ) {
424
424
if let Some ( ( cond, body, Some ( else_body) ) ) = higher:: if_block ( & expr) {
425
- if let ExprKind :: Block ( Block { stmts : [ ] , expr : Some ( Expr { kind : ExprKind :: Unary ( UnOp :: UnNeg , else_expr) , .. } ) , .. } , _, ) = else_body. kind {
426
- if let ExprKind :: Block ( Block { stmts : [ ] , expr : Some ( body) , .. } , _, ) = & body. kind {
425
+ if let ExprKind :: Block (
426
+ Block {
427
+ stmts : [ ] ,
428
+ expr :
429
+ Some ( Expr {
430
+ kind : ExprKind :: Unary ( UnOp :: UnNeg , else_expr) ,
431
+ ..
432
+ } ) ,
433
+ ..
434
+ } ,
435
+ _,
436
+ ) = else_body. kind
437
+ {
438
+ if let ExprKind :: Block (
439
+ Block {
440
+ stmts : [ ] ,
441
+ expr : Some ( body) ,
442
+ ..
443
+ } ,
444
+ _,
445
+ ) = & body. kind
446
+ {
427
447
if are_exprs_equal ( cx, else_expr, body) {
428
448
if is_testing_positive ( cx, cond, body) {
429
449
span_lint_and_sugg (
@@ -449,9 +469,28 @@ fn check_custom_abs(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
449
469
}
450
470
}
451
471
}
452
- if let ExprKind :: Block ( Block { stmts : [ ] , expr : Some ( Expr { kind : ExprKind :: Unary ( UnOp :: UnNeg , else_expr) , .. } ) , .. } , _, ) = & body. kind
472
+ if let ExprKind :: Block (
473
+ Block {
474
+ stmts : [ ] ,
475
+ expr :
476
+ Some ( Expr {
477
+ kind : ExprKind :: Unary ( UnOp :: UnNeg , else_expr) ,
478
+ ..
479
+ } ) ,
480
+ ..
481
+ } ,
482
+ _,
483
+ ) = & body. kind
453
484
{
454
- if let ExprKind :: Block ( Block { stmts : [ ] , expr : Some ( body) , .. } , _, ) = & else_body. kind {
485
+ if let ExprKind :: Block (
486
+ Block {
487
+ stmts : [ ] ,
488
+ expr : Some ( body) ,
489
+ ..
490
+ } ,
491
+ _,
492
+ ) = & else_body. kind
493
+ {
455
494
if are_exprs_equal ( cx, else_expr, body) {
456
495
if is_testing_negative ( cx, cond, body) {
457
496
span_lint_and_sugg (
0 commit comments