@@ -10,8 +10,8 @@ use rustc_span::Span;
1010
1111declare_clippy_lint ! {
1212 /// ### What it does
13- /// Checks for ranges which almost include the entire range of letters from 'a' to 'z', but
14- /// don't because they're a half open range.
13+ /// Checks for ranges which almost include the entire range of letters from 'a' to 'z'
14+ /// or digits from '0' to '9', but don't because they're a half open range.
1515 ///
1616 /// ### Why is this bad?
1717 /// This (`'a'..'z'`) is almost certainly a typo meant to include all letters.
@@ -25,21 +25,21 @@ declare_clippy_lint! {
2525 /// let _ = 'a'..='z';
2626 /// ```
2727 #[ clippy:: version = "1.63.0" ]
28- pub ALMOST_COMPLETE_LETTER_RANGE ,
28+ pub ALMOST_COMPLETE_RANGE ,
2929 suspicious,
30- "almost complete letter range"
30+ "almost complete range"
3131}
32- impl_lint_pass ! ( AlmostCompleteLetterRange => [ ALMOST_COMPLETE_LETTER_RANGE ] ) ;
32+ impl_lint_pass ! ( AlmostCompleteRange => [ ALMOST_COMPLETE_RANGE ] ) ;
3333
34- pub struct AlmostCompleteLetterRange {
34+ pub struct AlmostCompleteRange {
3535 msrv : Msrv ,
3636}
37- impl AlmostCompleteLetterRange {
37+ impl AlmostCompleteRange {
3838 pub fn new ( msrv : Msrv ) -> Self {
3939 Self { msrv }
4040 }
4141}
42- impl EarlyLintPass for AlmostCompleteLetterRange {
42+ impl EarlyLintPass for AlmostCompleteRange {
4343 fn check_expr ( & mut self , cx : & EarlyContext < ' _ > , e : & Expr ) {
4444 if let ExprKind :: Range ( Some ( start) , Some ( end) , RangeLimits :: HalfOpen ) = & e. kind {
4545 let ctxt = e. span . ctxt ( ) ;
@@ -87,14 +87,18 @@ fn check_range(cx: &EarlyContext<'_>, span: Span, start: &Expr, end: &Expr, sugg
8787 Ok ( LitKind :: Byte ( b'A' ) | LitKind :: Char ( 'A' ) ) ,
8888 Ok ( LitKind :: Byte ( b'Z' ) | LitKind :: Char ( 'Z' ) ) ,
8989 )
90+ | (
91+ Ok ( LitKind :: Byte ( b'0' ) | LitKind :: Char ( '0' ) ) ,
92+ Ok ( LitKind :: Byte ( b'9' ) | LitKind :: Char ( '9' ) ) ,
93+ )
9094 )
9195 && !in_external_macro ( cx. sess ( ) , span)
9296 {
9397 span_lint_and_then (
9498 cx,
95- ALMOST_COMPLETE_LETTER_RANGE ,
99+ ALMOST_COMPLETE_RANGE ,
96100 span,
97- "almost complete ascii letter range" ,
101+ "almost complete ascii range" ,
98102 |diag| {
99103 if let Some ( ( span, sugg) ) = sugg {
100104 diag. span_suggestion (
0 commit comments