Skip to content

Commit ab6b949

Browse files
committed
Refactor check_lit method
1 parent 1fd2451 commit ab6b949

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

clippy_lints/src/literal_representation.rs

+13-17
Original file line numberDiff line numberDiff line change
@@ -526,24 +526,20 @@ impl LiteralRepresentation {
526526
if let Some(src) = snippet_opt(cx, lit.span);
527527
if let Some(firstch) = src.chars().next();
528528
if char::to_digit(firstch, 10).is_some();
529+
let digit_info = DigitInfo::new(&src, false);
530+
if digit_info.radix == Radix::Decimal;
531+
if let Ok(val) = digit_info.digits
532+
.chars()
533+
.filter(|&c| c != '_')
534+
.collect::<String>()
535+
.parse::<u128>();
536+
if val >= u128::from(self.threshold);
529537
then {
530-
let digit_info = DigitInfo::new(&src, false);
531-
if digit_info.radix == Radix::Decimal {
532-
if let Ok(val) = digit_info.digits
533-
.chars()
534-
.filter(|&c| c != '_')
535-
.collect::<String>()
536-
.parse::<u128>() {
537-
if val < u128::from(self.threshold) {
538-
return
539-
}
540-
let hex = format!("{:#X}", val);
541-
let digit_info = DigitInfo::new(&hex, false);
542-
let _ = Self::do_lint(digit_info.digits).map_err(|warning_type| {
543-
warning_type.display(&digit_info.grouping_hint(), cx, lit.span)
544-
});
545-
};
546-
}
538+
let hex = format!("{:#X}", val);
539+
let digit_info = DigitInfo::new(&hex, false);
540+
let _ = Self::do_lint(digit_info.digits).map_err(|warning_type| {
541+
warning_type.display(&digit_info.grouping_hint(), cx, lit.span)
542+
});
547543
}
548544
}
549545
}

0 commit comments

Comments
 (0)