about summary refs log tree commit diff
diff options
context:
space:
mode:
authormlegner <markus@legner.ch>2020-03-04 10:12:11 +0100
committermlegner <markus@legner.ch>2020-03-04 13:22:54 +0100
commit185fa0d1b1ea7ba9677c7f3d6e2c3d5968f26539 (patch)
treef1f3088e6ad5145ff3f7ee32b4960537108f9885
parentd14fdc0203b8290df9527aa62c25a64922f8126a (diff)
downloadrust-185fa0d1b1ea7ba9677c7f3d6e2c3d5968f26539.tar.gz
rust-185fa0d1b1ea7ba9677c7f3d6e2c3d5968f26539.zip
Simplify if_chain.
-rw-r--r--clippy_lints/src/types.rs30
1 files changed, 14 insertions, 16 deletions
diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs
index 9bb054ec4e2..f96e797217f 100644
--- a/clippy_lints/src/types.rs
+++ b/clippy_lints/src/types.rs
@@ -1214,23 +1214,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Casts {
                     if let LitKind::Int(n, _) = lit.node;
                     if let Some(src) = snippet_opt(cx, lit.span);
                     if cast_to.is_floating_point();
+                    if let Some(num_lit) = NumericLiteral::from_lit_kind(&src, &lit.node);
+                    let from_nbits = 128 - n.leading_zeros();
+                    let to_nbits = fp_ty_mantissa_nbits(cast_to);
+                    if from_nbits != 0 && to_nbits != 0 && from_nbits <= to_nbits && num_lit.is_decimal();
                     then {
-                        let from_nbits = 128 - n.leading_zeros();
-                        let to_nbits = fp_ty_mantissa_nbits(cast_to);
-                        if let Some(num_lit) = NumericLiteral::from_lit_kind(&src, &lit.node) {
-                            if from_nbits != 0 && to_nbits != 0 && from_nbits <= to_nbits && num_lit.is_decimal() {
-                                span_lint_and_sugg(
-                                    cx,
-                                    UNNECESSARY_CAST,
-                                    expr.span,
-                                    &format!("casting integer literal to `{}` is unnecessary", cast_to),
-                                    "try",
-                                    format!("{}_{}", n, cast_to),
-                                    Applicability::MachineApplicable,
-                                );
-                                return;
-                            }
-                        }
+                        span_lint_and_sugg(
+                            cx,
+                            UNNECESSARY_CAST,
+                            expr.span,
+                            &format!("casting integer literal to `{}` is unnecessary", cast_to),
+                            "try",
+                            format!("{}_{}", n, cast_to),
+                            Applicability::MachineApplicable,
+                        );
+                        return;
                     }
                 }
                 match lit.node {