@@ -7,6 +7,7 @@ use clippy_utils::source::snippet;
7
7
use clippy_utils:: visitors:: for_each_expr;
8
8
use clippy_utils:: { eq_expr_value, hash_expr, higher} ;
9
9
use rustc_ast:: { LitKind , RangeLimits } ;
10
+ use rustc_data_structures:: packed:: Pu128 ;
10
11
use rustc_data_structures:: unhash:: UnhashMap ;
11
12
use rustc_errors:: { Applicability , Diagnostic } ;
12
13
use rustc_hir:: { BinOp , Block , Body , Expr , ExprKind , UnOp } ;
@@ -102,8 +103,8 @@ fn len_comparison<'hir>(
102
103
) -> Option < ( LengthComparison , usize , & ' hir Expr < ' hir > ) > {
103
104
macro_rules! int_lit_pat {
104
105
( $id: ident) => {
105
- ExprKind :: Lit ( Spanned {
106
- node: LitKind :: Int ( $id, _) ,
106
+ ExprKind :: Lit ( & Spanned {
107
+ node: LitKind :: Int ( Pu128 ( $id) , _) ,
107
108
..
108
109
} )
109
110
} ;
@@ -112,13 +113,13 @@ fn len_comparison<'hir>(
112
113
// normalize comparison, `v.len() > 4` becomes `4 < v.len()`
113
114
// this simplifies the logic a bit
114
115
let ( op, left, right) = normalize_comparison ( bin_op. node , left, right) ?;
115
- match ( op, & left. kind , & right. kind ) {
116
- ( Rel :: Lt , int_lit_pat ! ( left) , _) => Some ( ( LengthComparison :: IntLessThanLength , * left as usize , right) ) ,
117
- ( Rel :: Lt , _, int_lit_pat ! ( right) ) => Some ( ( LengthComparison :: LengthLessThanInt , * right as usize , left) ) ,
118
- ( Rel :: Le , int_lit_pat ! ( left) , _) => Some ( ( LengthComparison :: IntLessThanOrEqualLength , * left as usize , right) ) ,
119
- ( Rel :: Le , _, int_lit_pat ! ( right) ) => Some ( ( LengthComparison :: LengthLessThanOrEqualInt , * right as usize , left) ) ,
120
- ( Rel :: Eq , int_lit_pat ! ( left) , _) => Some ( ( LengthComparison :: LengthEqualInt , * left as usize , right) ) ,
121
- ( Rel :: Eq , _, int_lit_pat ! ( right) ) => Some ( ( LengthComparison :: LengthEqualInt , * right as usize , left) ) ,
116
+ match ( op, left. kind , right. kind ) {
117
+ ( Rel :: Lt , int_lit_pat ! ( left) , _) => Some ( ( LengthComparison :: IntLessThanLength , left as usize , right) ) ,
118
+ ( Rel :: Lt , _, int_lit_pat ! ( right) ) => Some ( ( LengthComparison :: LengthLessThanInt , right as usize , left) ) ,
119
+ ( Rel :: Le , int_lit_pat ! ( left) , _) => Some ( ( LengthComparison :: IntLessThanOrEqualLength , left as usize , right) ) ,
120
+ ( Rel :: Le , _, int_lit_pat ! ( right) ) => Some ( ( LengthComparison :: LengthLessThanOrEqualInt , right as usize , left) ) ,
121
+ ( Rel :: Eq , int_lit_pat ! ( left) , _) => Some ( ( LengthComparison :: LengthEqualInt , left as usize , right) ) ,
122
+ ( Rel :: Eq , _, int_lit_pat ! ( right) ) => Some ( ( LengthComparison :: LengthEqualInt , right as usize , left) ) ,
122
123
_ => None ,
123
124
}
124
125
}
@@ -206,14 +207,14 @@ impl<'hir> IndexEntry<'hir> {
206
207
/// for `..=5` this returns `Some(5)`
207
208
fn upper_index_expr ( expr : & Expr < ' _ > ) -> Option < usize > {
208
209
if let ExprKind :: Lit ( lit) = & expr. kind
209
- && let LitKind :: Int ( index, _) = lit. node
210
+ && let LitKind :: Int ( Pu128 ( index) , _) = lit. node
210
211
{
211
212
Some ( index as usize )
212
213
} else if let Some ( higher:: Range {
213
214
end : Some ( end) , limits, ..
214
215
} ) = higher:: Range :: hir ( expr)
215
216
&& let ExprKind :: Lit ( lit) = & end. kind
216
- && let LitKind :: Int ( index @ 1 .., _) = lit. node
217
+ && let LitKind :: Int ( Pu128 ( index @ 1 ..) , _) = lit. node
217
218
{
218
219
match limits {
219
220
RangeLimits :: HalfOpen => Some ( index as usize - 1 ) ,
0 commit comments