@@ -37,8 +37,8 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
3737 match ( & left. node , & right. node ) {
3838 ( & StmtDecl ( ref l, _) , & StmtDecl ( ref r, _) ) => {
3939 if let ( & DeclLocal ( ref l) , & DeclLocal ( ref r) ) = ( & l. node , & r. node ) {
40- // TODO: tys
41- l . ty . is_none ( ) && r . ty . is_none ( ) && both ( & l. init , & r. init , |l, r| self . eq_expr ( l, r) )
40+ both ( & l . ty , & r . ty , |l , r| self . eq_ty ( l , r ) ) &&
41+ both ( & l. init , & r. init , |l, r| self . eq_expr ( l, r) )
4242 } else {
4343 false
4444 }
@@ -85,7 +85,10 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
8585 ( & ExprCall ( ref l_fun, ref l_args) , & ExprCall ( ref r_fun, ref r_args) ) => {
8686 !self . ignore_fn && self . eq_expr ( l_fun, r_fun) && self . eq_exprs ( l_args, r_args)
8787 }
88- ( & ExprCast ( ref lx, ref lt) , & ExprCast ( ref rx, ref rt) ) => self . eq_expr ( lx, rx) && self . eq_ty ( lt, rt) ,
88+ ( & ExprCast ( ref lx, ref lt) , & ExprCast ( ref rx, ref rt) ) |
89+ ( & ExprType ( ref lx, ref lt) , & ExprType ( ref rx, ref rt) ) => {
90+ self . eq_expr ( lx, rx) && self . eq_ty ( lt, rt)
91+ }
8992 ( & ExprField ( ref l_f_exp, ref l_f_ident) , & ExprField ( ref r_f_exp, ref r_f_ident) ) => {
9093 l_f_ident. node == r_f_ident. node && self . eq_expr ( l_f_exp, r_f_exp)
9194 }
@@ -106,8 +109,8 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
106109 }
107110 ( & ExprMethodCall ( ref l_name, ref l_tys, ref l_args) ,
108111 & ExprMethodCall ( ref r_name, ref r_tys, ref r_args) ) => {
109- // TODO: tys
110- ! self . ignore_fn && l_name . node == r_name . node && l_tys . is_empty ( ) && r_tys . is_empty ( ) &&
112+ ! self . ignore_fn && l_name . node == r_name . node &&
113+ over ( l_tys , r_tys , |l , r| self . eq_ty ( l , r ) ) &&
111114 self . eq_exprs ( l_args, r_args)
112115 }
113116 ( & ExprRepeat ( ref le, ref ll) , & ExprRepeat ( ref re, ref rl) ) => self . eq_expr ( le, re) && self . eq_expr ( ll, rl) ,
@@ -138,6 +141,10 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
138141 left. name . node == right. name . node && self . eq_expr ( & left. expr , & right. expr )
139142 }
140143
144+ fn eq_lifetime ( & self , left : & Lifetime , right : & Lifetime ) -> bool {
145+ left. name == right. name
146+ }
147+
141148 /// Check whether two patterns are the same.
142149 pub fn eq_pat ( & self , left : & Pat , right : & Pat ) -> bool {
143150 match ( & left. node , & right. node ) {
@@ -169,12 +176,33 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
169176 }
170177
171178 fn eq_path ( & self , left : & Path , right : & Path ) -> bool {
179+ left. global == right. global &&
180+ over ( & left. segments , & right. segments , |l, r| self . eq_path_segment ( l, r) )
181+ }
182+
183+ fn eq_path_parameters ( & self , left : & PathParameters , right : & PathParameters ) -> bool {
184+ match ( left, right) {
185+ ( & AngleBracketedParameters ( ref left) , & AngleBracketedParameters ( ref right) ) => {
186+ over ( & left. lifetimes , & right. lifetimes , |l, r| self . eq_lifetime ( l, r) ) &&
187+ over ( & left. types , & right. types , |l, r| self . eq_ty ( l, r) ) &&
188+ over ( & left. bindings , & right. bindings , |l, r| self . eq_type_binding ( l, r) )
189+ }
190+ ( & ParenthesizedParameters ( ref left) , & ParenthesizedParameters ( ref right) ) => {
191+ over ( & left. inputs , & right. inputs , |l, r| self . eq_ty ( l, r) ) &&
192+ both ( & left. output , & right. output , |l, r| self . eq_ty ( l, r) )
193+ }
194+ ( & AngleBracketedParameters ( _) , & ParenthesizedParameters ( _) ) |
195+ ( & ParenthesizedParameters ( _) , & AngleBracketedParameters ( _) ) => {
196+ false
197+ }
198+ }
199+ }
200+
201+ fn eq_path_segment ( & self , left : & PathSegment , right : & PathSegment ) -> bool {
172202 // The == of idents doesn't work with different contexts,
173203 // we have to be explicit about hygiene
174- left. global == right. global &&
175- over ( & left. segments ,
176- & right. segments ,
177- |l, r| l. name . as_str ( ) == r. name . as_str ( ) && l. parameters == r. parameters )
204+ left. name . as_str ( ) == right. name . as_str ( ) &&
205+ self . eq_path_parameters ( & left. parameters , & right. parameters )
178206 }
179207
180208 fn eq_qself ( & self , left : & QSelf , right : & QSelf ) -> bool {
@@ -199,6 +227,10 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
199227 _ => false ,
200228 }
201229 }
230+
231+ fn eq_type_binding ( & self , left : & TypeBinding , right : & TypeBinding ) -> bool {
232+ left. name == right. name && self . eq_ty ( & left. ty , & right. ty )
233+ }
202234}
203235
204236fn swap_binop < ' a > ( binop : BinOp_ , lhs : & ' a Expr , rhs : & ' a Expr ) -> Option < ( BinOp_ , & ' a Expr , & ' a Expr ) > {
@@ -445,10 +477,11 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
445477 self . hash_expr ( le) ;
446478 li. node . hash ( & mut self . s ) ;
447479 }
448- ExprType ( _ , _ ) => {
480+ ExprType ( ref e , ref _ty ) => {
449481 let c: fn ( _, _) -> _ = ExprType ;
450482 c. hash ( & mut self . s ) ;
451- // what’s an ExprType anyway?
483+ self . hash_expr ( e) ;
484+ // TODO: _ty
452485 }
453486 ExprUnary ( lop, ref le) => {
454487 let c: fn ( _, _) -> _ = ExprUnary ;
@@ -495,10 +528,15 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
495528
496529 pub fn hash_stmt ( & mut self , b : & Stmt ) {
497530 match b. node {
498- StmtDecl ( ref _decl , _) => {
531+ StmtDecl ( ref decl , _) => {
499532 let c: fn ( _, _) -> _ = StmtDecl ;
500533 c. hash ( & mut self . s ) ;
501- // TODO: decl
534+
535+ if let DeclLocal ( ref local) = decl. node {
536+ if let Some ( ref init) = local. init {
537+ self . hash_expr ( init) ;
538+ }
539+ }
502540 }
503541 StmtExpr ( ref expr, _) => {
504542 let c: fn ( _, _) -> _ = StmtExpr ;
0 commit comments