@@ -7,9 +7,9 @@ use rustc_data_structures::fx::FxHasher;
7
7
use rustc_hir:: def:: Res ;
8
8
use rustc_hir:: MatchSource :: TryDesugar ;
9
9
use rustc_hir:: {
10
- ArrayLen , AssocItemConstraint , BinOpKind , BindingMode , Block , BodyId , Closure , Expr , ExprField , ExprKind , FnRetTy ,
11
- GenericArg , GenericArgs , HirId , HirIdMap , InlineAsmOperand , LetExpr , Lifetime , LifetimeName , Pat , PatField ,
12
- PatKind , Path , PathSegment , PrimTy , QPath , Stmt , StmtKind , Ty , TyKind ,
10
+ ArrayLen , AssocItemConstraint , BinOpKind , BindingMode , Block , BodyId , Closure , ConstArg , ConstArgKind , Expr ,
11
+ ExprField , ExprKind , FnRetTy , GenericArg , GenericArgs , HirId , HirIdMap , InlineAsmOperand , LetExpr , Lifetime ,
12
+ LifetimeName , Pat , PatField , PatKind , Path , PathSegment , PrimTy , QPath , Stmt , StmtKind , Ty , TyKind ,
13
13
} ;
14
14
use rustc_lexer:: { tokenize, TokenKind } ;
15
15
use rustc_lint:: LateContext ;
@@ -411,14 +411,20 @@ impl HirEqInterExpr<'_, '_, '_> {
411
411
412
412
fn eq_generic_arg ( & mut self , left : & GenericArg < ' _ > , right : & GenericArg < ' _ > ) -> bool {
413
413
match ( left, right) {
414
- ( GenericArg :: Const ( l) , GenericArg :: Const ( r) ) => self . eq_body ( l . value . body , r. value . body ) ,
414
+ ( GenericArg :: Const ( l) , GenericArg :: Const ( r) ) => self . eq_const_arg ( l , r) ,
415
415
( GenericArg :: Lifetime ( l_lt) , GenericArg :: Lifetime ( r_lt) ) => Self :: eq_lifetime ( l_lt, r_lt) ,
416
416
( GenericArg :: Type ( l_ty) , GenericArg :: Type ( r_ty) ) => self . eq_ty ( l_ty, r_ty) ,
417
417
( GenericArg :: Infer ( l_inf) , GenericArg :: Infer ( r_inf) ) => self . eq_ty ( & l_inf. to_ty ( ) , & r_inf. to_ty ( ) ) ,
418
418
_ => false ,
419
419
}
420
420
}
421
421
422
+ fn eq_const_arg ( & mut self , left : & ConstArg < ' _ > , right : & ConstArg < ' _ > ) -> bool {
423
+ match ( & left. kind , & right. kind ) {
424
+ ( ConstArgKind :: Anon ( l_an) , ConstArgKind :: Anon ( r_an) ) => self . eq_body ( l_an. body , r_an. body ) ,
425
+ }
426
+ }
427
+
422
428
fn eq_lifetime ( left : & Lifetime , right : & Lifetime ) -> bool {
423
429
left. res == right. res
424
430
}
@@ -1134,12 +1140,18 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
1134
1140
self . maybe_typeck_results = old_maybe_typeck_results;
1135
1141
}
1136
1142
1143
+ fn hash_const_arg ( & mut self , const_arg : & ConstArg < ' _ > ) {
1144
+ match & const_arg. kind {
1145
+ ConstArgKind :: Anon ( anon) => self . hash_body ( anon. body ) ,
1146
+ }
1147
+ }
1148
+
1137
1149
fn hash_generic_args ( & mut self , arg_list : & [ GenericArg < ' _ > ] ) {
1138
1150
for arg in arg_list {
1139
1151
match * arg {
1140
1152
GenericArg :: Lifetime ( l) => self . hash_lifetime ( l) ,
1141
1153
GenericArg :: Type ( ty) => self . hash_ty ( ty) ,
1142
- GenericArg :: Const ( ref ca) => self . hash_body ( ca. value . body ) ,
1154
+ GenericArg :: Const ( ref ca) => self . hash_const_arg ( ca) ,
1143
1155
GenericArg :: Infer ( ref inf) => self . hash_ty ( & inf. to_ty ( ) ) ,
1144
1156
}
1145
1157
}
0 commit comments