Run cargo dev fmt

This commit is contained in:
JarredAllen 2020-02-29 18:51:39 -08:00
parent 028cddb956
commit bfa2691559
2 changed files with 48 additions and 10 deletions

View File

@ -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(

View File

@ -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 {