From 4e82a19bd952d17079289f1b1c27a315468dbaeb Mon Sep 17 00:00:00 2001 From: Rajkumar Natarajan Date: Sun, 29 Nov 2020 00:38:28 -0500 Subject: [PATCH] 6399 Lint: is_ascii_digit instead of is_digit --- clippy_lints/src/doc.rs | 2 +- clippy_lints/src/misc_early.rs | 2 +- clippy_lints/src/non_expressive_names.rs | 2 +- clippy_lints/src/utils/numeric_literal.rs | 2 +- tests/ui/to_digit_is_some.fixed | 2 +- tests/ui/to_digit_is_some.rs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index edecba57e44f..040e96643467 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -543,7 +543,7 @@ fn check_word(cx: &LateContext<'_>, word: &str, span: Span) { /// letters (`Clippy` is ok) and one lower-case letter (`NASA` is ok). /// Plurals are also excluded (`IDs` is ok). fn is_camel_case(s: &str) -> bool { - if s.starts_with(|c: char| c.is_digit(10)) { + if s.starts_with(|c: char| c.is_ascii_digit()) { return false; } diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index 5bc45c87874b..c7a5a7984b14 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -425,7 +425,7 @@ impl MiscEarlyLints { // See for a regression. // FIXME: Find a better way to detect those cases. let lit_snip = match snippet_opt(cx, lit.span) { - Some(snip) if snip.chars().next().map_or(false, |c| c.is_digit(10)) => snip, + Some(snip) if snip.chars().next().map_or(false, |c| c.is_ascii_digit()) => snip, _ => return, }; diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index 5b42b61fcde9..11b3196f86db 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -190,7 +190,7 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> { if interned_name.chars().any(char::is_uppercase) { return; } - if interned_name.chars().all(|c| c.is_digit(10) || c == '_') { + if interned_name.chars().all(|c| c.is_ascii_digit() || c == '_') { span_lint( self.0.cx, JUST_UNDERSCORES_AND_DIGITS, diff --git a/clippy_lints/src/utils/numeric_literal.rs b/clippy_lints/src/utils/numeric_literal.rs index d02603d7702c..2fe94c90d9e5 100644 --- a/clippy_lints/src/utils/numeric_literal.rs +++ b/clippy_lints/src/utils/numeric_literal.rs @@ -50,7 +50,7 @@ impl<'a> NumericLiteral<'a> { } pub fn from_lit_kind(src: &'a str, lit_kind: &LitKind) -> Option> { - if lit_kind.is_numeric() && src.chars().next().map_or(false, |c| c.is_digit(10)) { + if lit_kind.is_numeric() && src.chars().next().map_or(false, |c| c.is_ascii_digit()) { let (unsuffixed, suffix) = split_suffix(&src, lit_kind); let float = matches!(lit_kind, LitKind::Float(..)); Some(NumericLiteral::new(unsuffixed, suffix, float)) diff --git a/tests/ui/to_digit_is_some.fixed b/tests/ui/to_digit_is_some.fixed index 19184df0becb..356c8a36f417 100644 --- a/tests/ui/to_digit_is_some.fixed +++ b/tests/ui/to_digit_is_some.fixed @@ -6,6 +6,6 @@ fn main() { let c = 'x'; let d = &c; - let _ = d.is_digit(10); + let _ = d.is_ascii_digit(); let _ = char::is_digit(c, 10); } diff --git a/tests/ui/to_digit_is_some.rs b/tests/ui/to_digit_is_some.rs index 45a6728ebf57..46570f96c476 100644 --- a/tests/ui/to_digit_is_some.rs +++ b/tests/ui/to_digit_is_some.rs @@ -6,6 +6,6 @@ fn main() { let c = 'x'; let d = &c; - let _ = d.to_digit(10).is_some(); + let _ = d.is_ascii_digit().is_some(); let _ = char::to_digit(c, 10).is_some(); }