about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Hansch <dev@phansch.net>2019-04-10 21:05:56 +0200
committerPhilipp Hansch <dev@phansch.net>2019-04-10 21:05:56 +0200
commitab6b949224a4704641e7c9d24163b9b99d3b47ea (patch)
tree808632241c96f9c4d3943eb1b4d430ee7ea8b3b2
parent1fd2451b901f26b3197b9c326ae8127f0788ef26 (diff)
downloadrust-ab6b949224a4704641e7c9d24163b9b99d3b47ea.tar.gz
rust-ab6b949224a4704641e7c9d24163b9b99d3b47ea.zip
Refactor check_lit method
-rw-r--r--clippy_lints/src/literal_representation.rs30
1 files changed, 13 insertions, 17 deletions
diff --git a/clippy_lints/src/literal_representation.rs b/clippy_lints/src/literal_representation.rs
index 6991be7d790..e97845314f9 100644
--- a/clippy_lints/src/literal_representation.rs
+++ b/clippy_lints/src/literal_representation.rs
@@ -526,24 +526,20 @@ impl LiteralRepresentation {
             if let Some(src) = snippet_opt(cx, lit.span);
             if let Some(firstch) = src.chars().next();
             if char::to_digit(firstch, 10).is_some();
+            let digit_info = DigitInfo::new(&src, false);
+            if digit_info.radix == Radix::Decimal;
+            if let Ok(val) = digit_info.digits
+                .chars()
+                .filter(|&c| c != '_')
+                .collect::<String>()
+                .parse::<u128>();
+            if val >= u128::from(self.threshold);
             then {
-                let digit_info = DigitInfo::new(&src, false);
-                if digit_info.radix == Radix::Decimal {
-                    if let Ok(val) = digit_info.digits
-                        .chars()
-                        .filter(|&c| c != '_')
-                        .collect::<String>()
-                        .parse::<u128>() {
-                        if val < u128::from(self.threshold) {
-                            return
-                        }
-                        let hex = format!("{:#X}", val);
-                        let digit_info = DigitInfo::new(&hex, false);
-                        let _ = Self::do_lint(digit_info.digits).map_err(|warning_type| {
-                            warning_type.display(&digit_info.grouping_hint(), cx, lit.span)
-                        });
-                    };
-                }
+                let hex = format!("{:#X}", val);
+                let digit_info = DigitInfo::new(&hex, false);
+                let _ = Self::do_lint(digit_info.digits).map_err(|warning_type| {
+                    warning_type.display(&digit_info.grouping_hint(), cx, lit.span)
+                });
             }
         }
     }