Refactor check_lit method

This commit is contained in:
Philipp Hansch 2019-04-10 21:05:56 +02:00
parent 1fd2451b90
commit ab6b949224
No known key found for this signature in database
GPG key ID: 82AA61CAA11397E6

View file

@ -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)
});
}
}
}