Run cargo dev fmt
This commit is contained in:
parent
028cddb956
commit
bfa2691559
@ -422,8 +422,28 @@ fn is_zero(expr: &Expr<'_>) -> bool {
|
||||
|
||||
fn check_custom_abs(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
|
||||
if let Some((cond, body, Some(else_body))) = higher::if_block(&expr) {
|
||||
if let ExprKind::Block( Block { stmts: [], expr: Some(Expr { kind: ExprKind::Unary(UnOp::UnNeg, else_expr), .. }), .. }, _,) = else_body.kind {
|
||||
if let ExprKind::Block( Block { stmts: [], expr: Some(body), .. }, _,) = &body.kind {
|
||||
if let ExprKind::Block(
|
||||
Block {
|
||||
stmts: [],
|
||||
expr:
|
||||
Some(Expr {
|
||||
kind: ExprKind::Unary(UnOp::UnNeg, else_expr),
|
||||
..
|
||||
}),
|
||||
..
|
||||
},
|
||||
_,
|
||||
) = else_body.kind
|
||||
{
|
||||
if let ExprKind::Block(
|
||||
Block {
|
||||
stmts: [],
|
||||
expr: Some(body),
|
||||
..
|
||||
},
|
||||
_,
|
||||
) = &body.kind
|
||||
{
|
||||
if are_exprs_equal(cx, else_expr, body) {
|
||||
if is_testing_positive(cx, cond, body) {
|
||||
span_lint_and_sugg(
|
||||
@ -449,9 +469,28 @@ fn check_custom_abs(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if let ExprKind::Block( Block { stmts: [], expr: Some(Expr { kind: ExprKind::Unary(UnOp::UnNeg, else_expr), .. }), .. }, _,) = &body.kind
|
||||
if let ExprKind::Block(
|
||||
Block {
|
||||
stmts: [],
|
||||
expr:
|
||||
Some(Expr {
|
||||
kind: ExprKind::Unary(UnOp::UnNeg, else_expr),
|
||||
..
|
||||
}),
|
||||
..
|
||||
},
|
||||
_,
|
||||
) = &body.kind
|
||||
{
|
||||
if let ExprKind::Block( Block { stmts: [], expr: Some(body), .. }, _,) = &else_body.kind {
|
||||
if let ExprKind::Block(
|
||||
Block {
|
||||
stmts: [],
|
||||
expr: Some(body),
|
||||
..
|
||||
},
|
||||
_,
|
||||
) = &else_body.kind
|
||||
{
|
||||
if are_exprs_equal(cx, else_expr, body) {
|
||||
if is_testing_negative(cx, cond, body) {
|
||||
span_lint_and_sugg(
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
struct A {
|
||||
a: f64,
|
||||
b: f64
|
||||
b: f64,
|
||||
}
|
||||
|
||||
fn fake_abs1(num: f64) -> f64 {
|
||||
@ -62,11 +62,10 @@ fn fake_nabs2(num: f64) -> f64 {
|
||||
}
|
||||
|
||||
fn fake_nabs3(a: A) -> A {
|
||||
A { a: if a.a >= 0.0 {
|
||||
-a.a
|
||||
} else {
|
||||
a.a
|
||||
}, b: a.b }
|
||||
A {
|
||||
a: if a.a >= 0.0 { -a.a } else { a.a },
|
||||
b: a.b,
|
||||
}
|
||||
}
|
||||
|
||||
fn not_fake_abs1(num: f64) -> f64 {
|
||||
|
Loading…
Reference in New Issue
Block a user