1 use clippy_utils::diagnostics::span_lint;
2 use rustc_ast::ast::Lit;
3 use rustc_lint::EarlyContext;
5 use super::MIXED_CASE_HEX_LITERALS;
7 pub(super) fn check(cx: &EarlyContext<'_>, lit: &Lit, suffix: &str, lit_snip: &str) {
8 let maybe_last_sep_idx = if let Some(val) = lit_snip.len().checked_sub(suffix.len() + 1) {
11 return; // It's useless so shouldn't lint.
13 if maybe_last_sep_idx <= 2 {
14 // It's meaningless or causes range error.
17 let mut seen = (false, false);
18 for ch in lit_snip.as_bytes()[2..=maybe_last_sep_idx].iter() {
20 b'a'..=b'f' => seen.0 = true,
21 b'A'..=b'F' => seen.1 = true,
27 MIXED_CASE_HEX_LITERALS,
29 "inconsistent casing in hexadecimal literal",