@@ -113,7 +113,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
113113 } ,
114114 ( & ExprKind :: Match ( ref le, ref la, ref ls) , & ExprKind :: Match ( ref re, ref ra, ref rs) ) => {
115115 ls == rs && self . eq_expr ( le, re) && over ( la, ra, |l, r| {
116- self . eq_expr ( & l. body , & r. body ) && both ( & l. guard , & r. guard , |l, r| self . eq_expr ( l, r) )
116+ self . eq_expr ( & l. body , & r. body ) && both ( & l. guard , & r. guard , |l, r| self . eq_guard ( l, r) )
117117 && over ( & l. pats , & r. pats , |l, r| self . eq_pat ( l, r) )
118118 } )
119119 } ,
@@ -152,6 +152,12 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
152152 left. ident . name == right. ident . name && self . eq_expr ( & left. expr , & right. expr )
153153 }
154154
155+ fn eq_guard ( & mut self , left : & Guard , right : & Guard ) -> bool {
156+ match ( left, right) {
157+ ( Guard :: If ( l) , Guard :: If ( r) ) => self . eq_expr ( l, r) ,
158+ }
159+ }
160+
155161 fn eq_generic_arg ( & mut self , left : & GenericArg , right : & GenericArg ) -> bool {
156162 match ( left, right) {
157163 ( GenericArg :: Lifetime ( l_lt) , GenericArg :: Lifetime ( r_lt) ) => self . eq_lifetime ( l_lt, r_lt) ,
@@ -497,7 +503,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
497503 for arm in arms {
498504 // TODO: arm.pat?
499505 if let Some ( ref e) = arm. guard {
500- self . hash_expr ( e) ;
506+ self . hash_guard ( e) ;
501507 }
502508 self . hash_expr ( & arm. body ) ;
503509 }
@@ -637,4 +643,14 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
637643 } ,
638644 }
639645 }
646+
647+ pub fn hash_guard ( & mut self , g : & Guard ) {
648+ match g {
649+ Guard :: If ( ref expr) => {
650+ let c: fn ( _) -> _ = Guard :: If ;
651+ c. hash ( & mut self . s ) ;
652+ self . hash_expr ( expr) ;
653+ }
654+ }
655+ }
640656}
0 commit comments