@@ -182,7 +182,6 @@ mod svh_visitor {
182182 SawMod ,
183183 SawForeignItem ,
184184 SawItem ,
185- SawDecl ,
186185 SawTy ,
187186 SawGenerics ,
188187 SawFn ,
@@ -285,24 +284,13 @@ mod svh_visitor {
285284 /// SawStmtComponent is analogous to SawExprComponent, but for statements.
286285 #[ derive( Hash ) ]
287286 pub enum SawStmtComponent {
288- SawStmtDecl ,
289287 SawStmtExpr ,
290288 SawStmtSemi ,
291289 }
292290
293- fn saw_stmt ( node : & Stmt_ ) -> SawStmtComponent {
294- match * node {
295- StmtDecl ( ..) => SawStmtDecl ,
296- StmtExpr ( ..) => SawStmtExpr ,
297- StmtSemi ( ..) => SawStmtSemi ,
298- }
299- }
300-
301291 impl < ' a , ' tcx > Visitor < ' a > for StrictVersionHashVisitor < ' a , ' tcx > {
302- fn visit_nested_item ( & mut self , item : ItemId ) {
303- let def_path = self . tcx . map . def_path_from_id ( item. id ) . unwrap ( ) ;
304- debug ! ( "visit_nested_item: def_path={:?} st={:?}" , def_path, self . st) ;
305- self . hash_def_path ( & def_path) ;
292+ fn visit_nested_item ( & mut self , _: ItemId ) {
293+ // Each item is hashed independently; ignore nested items.
306294 }
307295
308296 fn visit_variant_data ( & mut self , s : & ' a VariantData , name : Name ,
@@ -362,7 +350,20 @@ mod svh_visitor {
362350
363351 fn visit_stmt ( & mut self , s : & ' a Stmt ) {
364352 debug ! ( "visit_stmt: st={:?}" , self . st) ;
365- SawStmt ( saw_stmt ( & s. node ) ) . hash ( self . st ) ; visit:: walk_stmt ( self , s)
353+
354+ // We don't want to modify the hash for decls, because
355+ // they might be item decls (if they are local decls,
356+ // we'll hash that fact in visit_local); but we do want to
357+ // remember if this was a StmtExpr or StmtSemi (the later
358+ // had an explicit semi-colon; this affects the typing
359+ // rules).
360+ match s. node {
361+ StmtDecl ( ..) => ( ) ,
362+ StmtExpr ( ..) => SawStmt ( SawStmtExpr ) . hash ( self . st ) ,
363+ StmtSemi ( ..) => SawStmt ( SawStmtSemi ) . hash ( self . st ) ,
364+ }
365+
366+ visit:: walk_stmt ( self , s)
366367 }
367368
368369 fn visit_foreign_item ( & mut self , i : & ' a ForeignItem ) {
@@ -390,11 +391,6 @@ mod svh_visitor {
390391 SawMod . hash ( self . st ) ; visit:: walk_mod ( self , m, n)
391392 }
392393
393- fn visit_decl ( & mut self , d : & ' a Decl ) {
394- debug ! ( "visit_decl: st={:?}" , self . st) ;
395- SawDecl . hash ( self . st ) ; visit:: walk_decl ( self , d)
396- }
397-
398394 fn visit_ty ( & mut self , t : & ' a Ty ) {
399395 debug ! ( "visit_ty: st={:?}" , self . st) ;
400396 SawTy . hash ( self . st ) ; visit:: walk_ty ( self , t)
0 commit comments