mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Refactor check_lit method
This commit is contained in:
parent
1fd2451b90
commit
ab6b949224
1 changed files with 13 additions and 17 deletions
|
@ -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)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue