@@ -6,9 +6,9 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
6
6
use rustc_hir:: def:: Res ;
7
7
use rustc_hir:: HirIdMap ;
8
8
use 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 ,
12
12
} ;
13
13
use rustc_lexer:: { tokenize, TokenKind } ;
14
14
use rustc_lint:: LateContext ;
@@ -537,13 +537,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
537
537
self . hash_expr ( e) ;
538
538
}
539
539
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 ) ;
547
541
}
548
542
549
543
#[ allow( clippy:: many_single_char_names, clippy:: too_many_lines) ]
@@ -554,21 +548,16 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
554
548
555
549
// const hashing may result in the same hash as some unrelated node, so add a sort of
556
550
// 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 ;
561
554
}
562
555
563
556
std:: mem:: discriminant ( & e. kind ) . hash ( & mut self . s ) ;
564
557
565
558
match e. kind {
566
559
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 ) ;
572
561
m. hash ( & mut self . s ) ;
573
562
self . hash_expr ( e) ;
574
563
} ,
@@ -616,11 +605,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
616
605
self . hash_ty ( ty) ;
617
606
} ,
618
607
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 ) ;
624
609
// closures inherit TypeckResults
625
610
self . hash_expr ( & self . cx . tcx . hir ( ) . body ( eid) . value ) ;
626
611
} ,
@@ -694,8 +679,6 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
694
679
}
695
680
} ,
696
681
ExprKind :: If ( cond, then, ref else_opt) => {
697
- let c: fn ( _, _, _) -> _ = ExprKind :: If ;
698
- c. hash ( & mut self . s ) ;
699
682
self . hash_expr ( cond) ;
700
683
self . hash_expr ( then) ;
701
684
if let Some ( e) = * else_opt {
@@ -928,10 +911,9 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
928
911
for arg in bfn. decl . inputs {
929
912
self . hash_ty ( arg) ;
930
913
}
914
+ std:: mem:: discriminant ( & bfn. decl . output ) . hash ( & mut self . s ) ;
931
915
match bfn. decl . output {
932
- FnRetTy :: DefaultReturn ( _) => {
933
- ( ) . hash ( & mut self . s ) ;
934
- } ,
916
+ FnRetTy :: DefaultReturn ( _) => { } ,
935
917
FnRetTy :: Return ( ty) => {
936
918
self . hash_ty ( ty) ;
937
919
} ,
@@ -943,24 +925,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
943
925
self . hash_ty ( ty) ;
944
926
}
945
927
} ,
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) ,
964
929
TyKind :: OpaqueDef ( _, arg_list) => {
965
930
self . hash_generic_args ( arg_list) ;
966
931
} ,
0 commit comments