@@ -713,7 +713,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
713713 self . hash_expr ( e) ;
714714
715715 for arm in arms {
716- // TODO: arm.pat?
716+ self . hash_pat ( arm. pat ) ;
717717 if let Some ( ref e) = arm. guard {
718718 self . hash_guard ( e) ;
719719 }
@@ -791,6 +791,72 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
791791 // self.maybe_typeck_results.unwrap().qpath_res(p, id).hash(&mut self.s);
792792 }
793793
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+
794860 pub fn hash_path ( & mut self , path : & Path < ' _ > ) {
795861 match path. res {
796862 // constant hash since equality is dependant on inter-expression context
@@ -808,6 +874,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
808874
809875 match & b. kind {
810876 StmtKind :: Local ( local) => {
877+ self . hash_pat ( local. pat ) ;
811878 if let Some ( ref init) = local. init {
812879 self . hash_expr ( init) ;
813880 }
@@ -827,7 +894,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
827894 }
828895 }
829896
830- pub fn hash_lifetime ( & mut self , lifetime : & Lifetime ) {
897+ pub fn hash_lifetime ( & mut self , lifetime : Lifetime ) {
831898 std:: mem:: discriminant ( & lifetime. name ) . hash ( & mut self . s ) ;
832899 if let LifetimeName :: Param ( ref name) = lifetime. name {
833900 std:: mem:: discriminant ( name) . hash ( & mut self . s ) ;
@@ -844,24 +911,20 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
844911 }
845912
846913 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 {
853916 TyKind :: Slice ( ty) => {
854917 self . hash_ty ( ty) ;
855918 } ,
856919 TyKind :: Array ( ty, anon_const) => {
857920 self . hash_ty ( ty) ;
858921 self . hash_body ( anon_const. body ) ;
859922 } ,
860- TyKind :: Ptr ( mut_ty) => {
923+ TyKind :: Ptr ( ref mut_ty) => {
861924 self . hash_ty ( & mut_ty. ty ) ;
862925 mut_ty. mutbl . hash ( & mut self . s ) ;
863926 } ,
864- TyKind :: Rptr ( lifetime, mut_ty) => {
927+ TyKind :: Rptr ( lifetime, ref mut_ty) => {
865928 self . hash_lifetime ( lifetime) ;
866929 self . hash_ty ( & mut_ty. ty ) ;
867930 mut_ty. mutbl . hash ( & mut self . s ) ;
@@ -883,11 +946,11 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
883946 bfn. decl . c_variadic . hash ( & mut self . s ) ;
884947 } ,
885948 TyKind :: Tup ( ty_list) => {
886- for ty in * ty_list {
949+ for ty in ty_list {
887950 self . hash_ty ( ty) ;
888951 }
889952 } ,
890- TyKind :: Path ( qpath) => match qpath {
953+ TyKind :: Path ( ref qpath) => match qpath {
891954 QPath :: Resolved ( ref maybe_ty, ref path) => {
892955 if let Some ( ref ty) = maybe_ty {
893956 self . hash_ty ( ty) ;
@@ -927,9 +990,9 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
927990
928991 fn hash_generic_args ( & mut self , arg_list : & [ GenericArg < ' _ > ] ) {
929992 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) ,
933996 GenericArg :: Const ( ref ca) => self . hash_body ( ca. value . body ) ,
934997 }
935998 }
0 commit comments