@@ -6,9 +6,9 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
66use rustc_hir:: def:: Res ;
77use rustc_hir:: HirIdMap ;
88use rustc_hir:: {
9- BinOpKind , Block , BlockCheckMode , BodyId , BorrowKind , CaptureBy , Expr , ExprField , ExprKind , FnRetTy , GenericArg ,
10- GenericArgs , Guard , HirId , InlineAsmOperand , Lifetime , LifetimeName , ParamName , Pat , PatField , PatKind , Path ,
11- PathSegment , QPath , Stmt , StmtKind , Ty , TyKind , TypeBinding ,
9+ BinOpKind , Block , BodyId , Expr , ExprField , ExprKind , FnRetTy , GenericArg , GenericArgs , Guard , HirId ,
10+ InlineAsmOperand , Lifetime , LifetimeName , ParamName , Pat , PatField , PatKind , Path , PathSegment , QPath , Stmt ,
11+ StmtKind , Ty , TyKind , TypeBinding ,
1212} ;
1313use rustc_lexer:: { tokenize, TokenKind } ;
1414use rustc_lint:: LateContext ;
@@ -537,13 +537,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
537537 self . hash_expr ( e) ;
538538 }
539539
540- match b. rules {
541- BlockCheckMode :: DefaultBlock => 0 ,
542- BlockCheckMode :: UnsafeBlock ( _) => 1 ,
543- BlockCheckMode :: PushUnsafeBlock ( _) => 2 ,
544- BlockCheckMode :: PopUnsafeBlock ( _) => 3 ,
545- }
546- . hash ( & mut self . s ) ;
540+ std:: mem:: discriminant ( & b. rules ) . hash ( & mut self . s ) ;
547541 }
548542
549543 #[ allow( clippy:: many_single_char_names, clippy:: too_many_lines) ]
@@ -554,21 +548,16 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
554548
555549 // const hashing may result in the same hash as some unrelated node, so add a sort of
556550 // discriminant depending on which path we're choosing next
557- simple_const. is_some ( ) . hash ( & mut self . s ) ;
558-
559- if let Some ( e) = simple_const {
560- return e. hash ( & mut self . s ) ;
551+ simple_const. hash ( & mut self . s ) ;
552+ if simple_const. is_some ( ) {
553+ return ;
561554 }
562555
563556 std:: mem:: discriminant ( & e. kind ) . hash ( & mut self . s ) ;
564557
565558 match e. kind {
566559 ExprKind :: AddrOf ( kind, m, e) => {
567- match kind {
568- BorrowKind :: Ref => 0 ,
569- BorrowKind :: Raw => 1 ,
570- }
571- . hash ( & mut self . s ) ;
560+ std:: mem:: discriminant ( & kind) . hash ( & mut self . s ) ;
572561 m. hash ( & mut self . s ) ;
573562 self . hash_expr ( e) ;
574563 } ,
@@ -616,11 +605,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
616605 self . hash_ty ( ty) ;
617606 } ,
618607 ExprKind :: Closure ( cap, _, eid, _, _) => {
619- match cap {
620- CaptureBy :: Value => 0 ,
621- CaptureBy :: Ref => 1 ,
622- }
623- . hash ( & mut self . s ) ;
608+ std:: mem:: discriminant ( & cap) . hash ( & mut self . s ) ;
624609 // closures inherit TypeckResults
625610 self . hash_expr ( & self . cx . tcx . hir ( ) . body ( eid) . value ) ;
626611 } ,
@@ -694,8 +679,6 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
694679 }
695680 } ,
696681 ExprKind :: If ( cond, then, ref else_opt) => {
697- let c: fn ( _, _, _) -> _ = ExprKind :: If ;
698- c. hash ( & mut self . s ) ;
699682 self . hash_expr ( cond) ;
700683 self . hash_expr ( then) ;
701684 if let Some ( e) = * else_opt {
@@ -928,10 +911,9 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
928911 for arg in bfn. decl . inputs {
929912 self . hash_ty ( arg) ;
930913 }
914+ std:: mem:: discriminant ( & bfn. decl . output ) . hash ( & mut self . s ) ;
931915 match bfn. decl . output {
932- FnRetTy :: DefaultReturn ( _) => {
933- ( ) . hash ( & mut self . s ) ;
934- } ,
916+ FnRetTy :: DefaultReturn ( _) => { } ,
935917 FnRetTy :: Return ( ty) => {
936918 self . hash_ty ( ty) ;
937919 } ,
@@ -943,24 +925,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
943925 self . hash_ty ( ty) ;
944926 }
945927 } ,
946- TyKind :: Path ( ref qpath) => match qpath {
947- QPath :: Resolved ( ref maybe_ty, path) => {
948- if let Some ( ty) = maybe_ty {
949- self . hash_ty ( ty) ;
950- }
951- for segment in path. segments {
952- segment. ident . name . hash ( & mut self . s ) ;
953- self . hash_generic_args ( segment. args ( ) . args ) ;
954- }
955- } ,
956- QPath :: TypeRelative ( ty, segment) => {
957- self . hash_ty ( ty) ;
958- segment. ident . name . hash ( & mut self . s ) ;
959- } ,
960- QPath :: LangItem ( lang_item, ..) => {
961- lang_item. hash ( & mut self . s ) ;
962- } ,
963- } ,
928+ TyKind :: Path ( ref qpath) => self . hash_qpath ( qpath) ,
964929 TyKind :: OpaqueDef ( _, arg_list) => {
965930 self . hash_generic_args ( arg_list) ;
966931 } ,
0 commit comments