- if seen.0 && seen.1 {
- span_lint(cx, MIXED_CASE_HEX_LITERALS, lit.span,
- "inconsistent casing in hexadecimal literal");
+ if src.starts_with("0x") {
+ let mut seen = (false, false);
+ for ch in src.chars() {
+ match ch {
+ 'a' ... 'f' => seen.0 = true,
+ 'A' ... 'F' => seen.1 = true,
+ 'i' | 'u' => break, // start of suffix already
+ _ => ()
+ }
+ }
+ if seen.0 && seen.1 {
+ span_lint(cx, MIXED_CASE_HEX_LITERALS, lit.span,
+ "inconsistent casing in hexadecimal literal");
+ }
+ }
+ }}
+ if_let_chain! {[
+ let LitKind::Float(..) = lit.node,
+ let Some(src) = snippet_opt(cx, lit.span),
+ let Some(firstch) = src.chars().next(),
+ char::to_digit(firstch, 10).is_some()
+ ], {
+ let mut prev = '\0';
+ for ch in src.chars() {
+ if ch == 'f' {
+ if prev != '_' {
+ span_lint(cx, UNSEPARATED_LITERAL_SUFFIX, lit.span,
+ "float type suffix should be separated by an underscore");
+ }
+ break;
+ }
+ prev = ch;