@@ -37,8 +37,8 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
37
37
match ( & left. node , & right. node ) {
38
38
( & StmtDecl ( ref l, _) , & StmtDecl ( ref r, _) ) => {
39
39
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) )
42
42
} else {
43
43
false
44
44
}
@@ -85,7 +85,10 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
85
85
( & ExprCall ( ref l_fun, ref l_args) , & ExprCall ( ref r_fun, ref r_args) ) => {
86
86
!self . ignore_fn && self . eq_expr ( l_fun, r_fun) && self . eq_exprs ( l_args, r_args)
87
87
}
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
+ }
89
92
( & ExprField ( ref l_f_exp, ref l_f_ident) , & ExprField ( ref r_f_exp, ref r_f_ident) ) => {
90
93
l_f_ident. node == r_f_ident. node && self . eq_expr ( l_f_exp, r_f_exp)
91
94
}
@@ -106,8 +109,8 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
106
109
}
107
110
( & ExprMethodCall ( ref l_name, ref l_tys, ref l_args) ,
108
111
& 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 ) ) &&
111
114
self . eq_exprs ( l_args, r_args)
112
115
}
113
116
( & 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> {
138
141
left. name . node == right. name . node && self . eq_expr ( & left. expr , & right. expr )
139
142
}
140
143
144
+ fn eq_lifetime ( & self , left : & Lifetime , right : & Lifetime ) -> bool {
145
+ left. name == right. name
146
+ }
147
+
141
148
/// Check whether two patterns are the same.
142
149
pub fn eq_pat ( & self , left : & Pat , right : & Pat ) -> bool {
143
150
match ( & left. node , & right. node ) {
@@ -169,12 +176,33 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
169
176
}
170
177
171
178
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 {
172
202
// The == of idents doesn't work with different contexts,
173
203
// 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 )
178
206
}
179
207
180
208
fn eq_qself ( & self , left : & QSelf , right : & QSelf ) -> bool {
@@ -199,6 +227,10 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
199
227
_ => false ,
200
228
}
201
229
}
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
+ }
202
234
}
203
235
204
236
fn 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> {
445
477
self . hash_expr ( le) ;
446
478
li. node . hash ( & mut self . s ) ;
447
479
}
448
- ExprType ( _ , _ ) => {
480
+ ExprType ( ref e , ref _ty ) => {
449
481
let c: fn ( _, _) -> _ = ExprType ;
450
482
c. hash ( & mut self . s ) ;
451
- // what’s an ExprType anyway?
483
+ self . hash_expr ( e) ;
484
+ // TODO: _ty
452
485
}
453
486
ExprUnary ( lop, ref le) => {
454
487
let c: fn ( _, _) -> _ = ExprUnary ;
@@ -495,10 +528,15 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
495
528
496
529
pub fn hash_stmt ( & mut self , b : & Stmt ) {
497
530
match b. node {
498
- StmtDecl ( ref _decl , _) => {
531
+ StmtDecl ( ref decl , _) => {
499
532
let c: fn ( _, _) -> _ = StmtDecl ;
500
533
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
+ }
502
540
}
503
541
StmtExpr ( ref expr, _) => {
504
542
let c: fn ( _, _) -> _ = StmtExpr ;
0 commit comments