Skip to content

Commit

Permalink
Refactor check_lit method
Browse files Browse the repository at this point in the history
  • Loading branch information
phansch committed Apr 10, 2019
1 parent 1fd2451 commit ab6b949
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions clippy_lints/src/literal_representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});
}
}
}
Expand Down

0 comments on commit ab6b949

Please sign in to comment.