@@ -2,10 +2,11 @@ use crate::consts::{constant_context, constant_simple};
22use crate :: utils:: differing_macro_contexts;
33use rustc:: hir:: ptr:: P ;
44use rustc:: hir:: * ;
5+ use rustc:: ich:: StableHashingContextProvider ;
56use rustc:: lint:: LateContext ;
67use rustc:: ty:: TypeckTables ;
7- use std :: collections :: hash_map :: DefaultHasher ;
8- use std:: hash:: { Hash , Hasher } ;
8+ use rustc_data_structures :: stable_hasher :: { HashStable , StableHasher } ;
9+ use std:: hash:: Hash ;
910use syntax:: ast:: Name ;
1011
1112/// Type used to check whether two ast are the same. This is different from the
@@ -348,19 +349,19 @@ pub struct SpanlessHash<'a, 'tcx> {
348349 /// Context used to evaluate constant expressions.
349350 cx : & ' a LateContext < ' a , ' tcx > ,
350351 tables : & ' a TypeckTables < ' tcx > ,
351- s : DefaultHasher ,
352+ s : StableHasher ,
352353}
353354
354355impl < ' a , ' tcx > SpanlessHash < ' a , ' tcx > {
355356 pub fn new ( cx : & ' a LateContext < ' a , ' tcx > , tables : & ' a TypeckTables < ' tcx > ) -> Self {
356357 Self {
357358 cx,
358359 tables,
359- s : DefaultHasher :: new ( ) ,
360+ s : StableHasher :: new ( ) ,
360361 }
361362 }
362363
363- pub fn finish ( & self ) -> u64 {
364+ pub fn finish ( self ) -> u64 {
364365 self . s . finish ( )
365366 }
366367
@@ -411,15 +412,17 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
411412 self . hash_expr ( r) ;
412413 } ,
413414 ExprKind :: AssignOp ( ref o, ref l, ref r) => {
414- o. hash ( & mut self . s ) ;
415+ o. node
416+ . hash_stable ( & mut self . cx . tcx . get_stable_hashing_context ( ) , & mut self . s ) ;
415417 self . hash_expr ( l) ;
416418 self . hash_expr ( r) ;
417419 } ,
418420 ExprKind :: Block ( ref b, _) => {
419421 self . hash_block ( b) ;
420422 } ,
421423 ExprKind :: Binary ( op, ref l, ref r) => {
422- op. node . hash ( & mut self . s ) ;
424+ op. node
425+ . hash_stable ( & mut self . cx . tcx . get_stable_hashing_context ( ) , & mut self . s ) ;
423426 self . hash_expr ( l) ;
424427 self . hash_expr ( r) ;
425428 } ,
@@ -460,7 +463,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
460463 } ,
461464 ExprKind :: InlineAsm ( ..) | ExprKind :: Err => { } ,
462465 ExprKind :: Lit ( ref l) => {
463- l. hash ( & mut self . s ) ;
466+ l. node . hash ( & mut self . s ) ;
464467 } ,
465468 ExprKind :: Loop ( ref b, ref i, _) => {
466469 self . hash_block ( b) ;
@@ -519,7 +522,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
519522 self . hash_exprs ( v) ;
520523 } ,
521524 ExprKind :: Unary ( lop, ref le) => {
522- lop. hash ( & mut self . s ) ;
525+ lop. hash_stable ( & mut self . cx . tcx . get_stable_hashing_context ( ) , & mut self . s ) ;
523526 self . hash_expr ( le) ;
524527 } ,
525528 }
0 commit comments