@@ -7,9 +7,9 @@ use rustc_data_structures::fx::FxHasher;
77use rustc_hir:: def:: Res ;
88use rustc_hir:: MatchSource :: TryDesugar ;
99use 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 ,
1313} ;
1414use rustc_lexer:: { tokenize, TokenKind } ;
1515use rustc_lint:: LateContext ;
@@ -411,14 +411,20 @@ impl HirEqInterExpr<'_, '_, '_> {
411411
412412 fn eq_generic_arg ( & mut self , left : & GenericArg < ' _ > , right : & GenericArg < ' _ > ) -> bool {
413413 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) ,
415415 ( GenericArg :: Lifetime ( l_lt) , GenericArg :: Lifetime ( r_lt) ) => Self :: eq_lifetime ( l_lt, r_lt) ,
416416 ( GenericArg :: Type ( l_ty) , GenericArg :: Type ( r_ty) ) => self . eq_ty ( l_ty, r_ty) ,
417417 ( GenericArg :: Infer ( l_inf) , GenericArg :: Infer ( r_inf) ) => self . eq_ty ( & l_inf. to_ty ( ) , & r_inf. to_ty ( ) ) ,
418418 _ => false ,
419419 }
420420 }
421421
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+
422428 fn eq_lifetime ( left : & Lifetime , right : & Lifetime ) -> bool {
423429 left. res == right. res
424430 }
@@ -1134,12 +1140,18 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
11341140 self . maybe_typeck_results = old_maybe_typeck_results;
11351141 }
11361142
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+
11371149 fn hash_generic_args ( & mut self , arg_list : & [ GenericArg < ' _ > ] ) {
11381150 for arg in arg_list {
11391151 match * arg {
11401152 GenericArg :: Lifetime ( l) => self . hash_lifetime ( l) ,
11411153 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) ,
11431155 GenericArg :: Infer ( ref inf) => self . hash_ty ( & inf. to_ty ( ) ) ,
11441156 }
11451157 }
0 commit comments