From ab6b949224a4704641e7c9d24163b9b99d3b47ea Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Wed, 10 Apr 2019 21:05:56 +0200 Subject: [PATCH] Refactor check_lit method --- clippy_lints/src/literal_representation.rs | 30 ++++++++++------------ 1 file 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::() + .parse::(); + 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::() - .parse::() { - 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) + }); } } }