From: Philipp Hansch Date: Wed, 10 Apr 2019 19:05:56 +0000 (+0200) Subject: Refactor check_lit method X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=ab6b949224a4704641e7c9d24163b9b99d3b47ea;p=rust.git Refactor check_lit method --- 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 @@ fn check_lit(self, cx: &EarlyContext<'_>, lit: &Lit) { 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) + }); } } }