@@ -713,7 +713,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
713
713
self . hash_expr ( e) ;
714
714
715
715
for arm in arms {
716
- // TODO: arm.pat?
716
+ self . hash_pat ( arm. pat ) ;
717
717
if let Some ( ref e) = arm. guard {
718
718
self . hash_guard ( e) ;
719
719
}
@@ -791,6 +791,72 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
791
791
// self.maybe_typeck_results.unwrap().qpath_res(p, id).hash(&mut self.s);
792
792
}
793
793
794
+ pub fn hash_pat ( & mut self , pat : & Pat < ' _ > ) {
795
+ std:: mem:: discriminant ( & pat. kind ) . hash ( & mut self . s ) ;
796
+ match pat. kind {
797
+ PatKind :: Binding ( ann, _, _, pat) => {
798
+ ann. hash_stable ( & mut self . cx . tcx . get_stable_hashing_context ( ) , & mut self . s ) ;
799
+ if let Some ( pat) = pat {
800
+ self . hash_pat ( pat) ;
801
+ }
802
+ } ,
803
+ PatKind :: Box ( pat) => self . hash_pat ( pat) ,
804
+ PatKind :: Lit ( expr) => self . hash_expr ( expr) ,
805
+ PatKind :: Or ( pats) => {
806
+ for pat in pats {
807
+ self . hash_pat ( pat) ;
808
+ }
809
+ } ,
810
+ PatKind :: Path ( ref qpath) => self . hash_qpath ( qpath) ,
811
+ PatKind :: Range ( s, e, i) => {
812
+ if let Some ( s) = s {
813
+ self . hash_expr ( s) ;
814
+ }
815
+ if let Some ( e) = e {
816
+ self . hash_expr ( e) ;
817
+ }
818
+ i. hash_stable ( & mut self . cx . tcx . get_stable_hashing_context ( ) , & mut self . s ) ;
819
+ } ,
820
+ PatKind :: Ref ( pat, m) => {
821
+ self . hash_pat ( pat) ;
822
+ m. hash ( & mut self . s ) ;
823
+ } ,
824
+ PatKind :: Slice ( l, m, r) => {
825
+ for pat in l {
826
+ self . hash_pat ( pat) ;
827
+ }
828
+ if let Some ( pat) = m {
829
+ self . hash_pat ( pat) ;
830
+ }
831
+ for pat in r {
832
+ self . hash_pat ( pat) ;
833
+ }
834
+ } ,
835
+ PatKind :: Struct ( ref qpath, fields, e) => {
836
+ self . hash_qpath ( qpath) ;
837
+ for f in fields {
838
+ self . hash_name ( f. ident . name ) ;
839
+ self . hash_pat ( f. pat ) ;
840
+ }
841
+ e. hash ( & mut self . s )
842
+ } ,
843
+ PatKind :: Tuple ( pats, e) => {
844
+ for pat in pats {
845
+ self . hash_pat ( pat) ;
846
+ }
847
+ e. hash ( & mut self . s ) ;
848
+ } ,
849
+ PatKind :: TupleStruct ( ref qpath, pats, e) => {
850
+ self . hash_qpath ( qpath) ;
851
+ for pat in pats {
852
+ self . hash_pat ( pat) ;
853
+ }
854
+ e. hash ( & mut self . s ) ;
855
+ } ,
856
+ PatKind :: Wild => { } ,
857
+ }
858
+ }
859
+
794
860
pub fn hash_path ( & mut self , path : & Path < ' _ > ) {
795
861
match path. res {
796
862
// constant hash since equality is dependant on inter-expression context
@@ -808,6 +874,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
808
874
809
875
match & b. kind {
810
876
StmtKind :: Local ( local) => {
877
+ self . hash_pat ( local. pat ) ;
811
878
if let Some ( ref init) = local. init {
812
879
self . hash_expr ( init) ;
813
880
}
@@ -827,7 +894,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
827
894
}
828
895
}
829
896
830
- pub fn hash_lifetime ( & mut self , lifetime : & Lifetime ) {
897
+ pub fn hash_lifetime ( & mut self , lifetime : Lifetime ) {
831
898
std:: mem:: discriminant ( & lifetime. name ) . hash ( & mut self . s ) ;
832
899
if let LifetimeName :: Param ( ref name) = lifetime. name {
833
900
std:: mem:: discriminant ( name) . hash ( & mut self . s ) ;
@@ -844,24 +911,20 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
844
911
}
845
912
846
913
pub fn hash_ty ( & mut self , ty : & Ty < ' _ > ) {
847
- self . hash_tykind ( & ty. kind ) ;
848
- }
849
-
850
- pub fn hash_tykind ( & mut self , ty : & TyKind < ' _ > ) {
851
- std:: mem:: discriminant ( ty) . hash ( & mut self . s ) ;
852
- match ty {
914
+ std:: mem:: discriminant ( & ty. kind ) . hash ( & mut self . s ) ;
915
+ match ty. kind {
853
916
TyKind :: Slice ( ty) => {
854
917
self . hash_ty ( ty) ;
855
918
} ,
856
919
TyKind :: Array ( ty, anon_const) => {
857
920
self . hash_ty ( ty) ;
858
921
self . hash_body ( anon_const. body ) ;
859
922
} ,
860
- TyKind :: Ptr ( mut_ty) => {
923
+ TyKind :: Ptr ( ref mut_ty) => {
861
924
self . hash_ty ( & mut_ty. ty ) ;
862
925
mut_ty. mutbl . hash ( & mut self . s ) ;
863
926
} ,
864
- TyKind :: Rptr ( lifetime, mut_ty) => {
927
+ TyKind :: Rptr ( lifetime, ref mut_ty) => {
865
928
self . hash_lifetime ( lifetime) ;
866
929
self . hash_ty ( & mut_ty. ty ) ;
867
930
mut_ty. mutbl . hash ( & mut self . s ) ;
@@ -883,11 +946,11 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
883
946
bfn. decl . c_variadic . hash ( & mut self . s ) ;
884
947
} ,
885
948
TyKind :: Tup ( ty_list) => {
886
- for ty in * ty_list {
949
+ for ty in ty_list {
887
950
self . hash_ty ( ty) ;
888
951
}
889
952
} ,
890
- TyKind :: Path ( qpath) => match qpath {
953
+ TyKind :: Path ( ref qpath) => match qpath {
891
954
QPath :: Resolved ( ref maybe_ty, ref path) => {
892
955
if let Some ( ref ty) = maybe_ty {
893
956
self . hash_ty ( ty) ;
@@ -927,9 +990,9 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
927
990
928
991
fn hash_generic_args ( & mut self , arg_list : & [ GenericArg < ' _ > ] ) {
929
992
for arg in arg_list {
930
- match arg {
931
- GenericArg :: Lifetime ( ref l) => self . hash_lifetime ( l) ,
932
- GenericArg :: Type ( ref ty) => self . hash_ty ( & ty) ,
993
+ match * arg {
994
+ GenericArg :: Lifetime ( l) => self . hash_lifetime ( l) ,
995
+ GenericArg :: Type ( ref ty) => self . hash_ty ( ty) ,
933
996
GenericArg :: Const ( ref ca) => self . hash_body ( ca. value . body ) ,
934
997
}
935
998
}
0 commit comments