literal representation restructure 1
Combine macro expansion checks. Indentation is a little strange to avoid rustfmt issue.
This commit is contained in:
parent
180f87065f
commit
8f5b4f3f5c
@ -358,28 +358,24 @@ impl EarlyLintPass for LiteralDigitGrouping {
|
||||
impl LiteralDigitGrouping {
|
||||
fn check_lit(cx: &EarlyContext<'_>, lit: &Lit) {
|
||||
let in_macro = in_macro(lit.span);
|
||||
match lit.kind {
|
||||
LitKind::Int(..) => {
|
||||
// Lint integral literals.
|
||||
|
||||
if_chain! {
|
||||
if let Some(src) = snippet_opt(cx, lit.span);
|
||||
if let Some(firstch) = src.chars().next();
|
||||
if char::is_digit(firstch, 10);
|
||||
then {
|
||||
|
||||
|
||||
match lit.kind {
|
||||
LitKind::Int(..) => {
|
||||
// Lint integral literals.
|
||||
let digit_info = DigitInfo::new(&src, false);
|
||||
let _ = Self::do_lint(digit_info.digits, digit_info.suffix, in_macro).map_err(|warning_type| {
|
||||
warning_type.display(&digit_info.grouping_hint(), cx, lit.span)
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
LitKind::Float(..) => {
|
||||
// Lint floating-point literals.
|
||||
if_chain! {
|
||||
if let Some(src) = snippet_opt(cx, lit.span);
|
||||
if let Some(firstch) = src.chars().next();
|
||||
if char::is_digit(firstch, 10);
|
||||
then {
|
||||
let digit_info = DigitInfo::new(&src, true);
|
||||
// Separate digits into integral and fractional parts.
|
||||
let parts: Vec<&str> = digit_info
|
||||
@ -414,12 +410,12 @@ impl LiteralDigitGrouping {
|
||||
}
|
||||
})
|
||||
.map_err(|warning_type| warning_type.display(&digit_info.grouping_hint(), cx, lit.span));
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Given the sizes of the digit groups of both integral and fractional
|
||||
/// parts, and the length
|
||||
|
Loading…
x
Reference in New Issue
Block a user