@@ -28,7 +28,7 @@ use rustc::hir::def_id::DefId;
28
28
use rustc:: hir:: intravisit as visit;
29
29
use rustc:: ty:: TyCtxt ;
30
30
use rustc_data_structures:: fnv;
31
- use std:: hash:: Hash ;
31
+ use std:: hash:: { Hash , Hasher } ;
32
32
33
33
use super :: def_path_hash:: DefPathHashes ;
34
34
use super :: caching_codemap_view:: CachingCodemapView ;
@@ -265,7 +265,7 @@ enum SawExprComponent<'a> {
265
265
SawExprPath ,
266
266
SawExprAddrOf ( hir:: Mutability ) ,
267
267
SawExprRet ,
268
- SawExprInlineAsm ( & ' a hir :: InlineAsm ) ,
268
+ SawExprInlineAsm ( StableInlineAsm < ' a > ) ,
269
269
SawExprStruct ,
270
270
SawExprRepeat ,
271
271
}
@@ -341,7 +341,7 @@ fn saw_expr<'a>(node: &'a Expr_,
341
341
ExprBreak ( label, _) => ( SawExprBreak ( label. map ( |l| l. name . as_str ( ) ) ) , false ) ,
342
342
ExprAgain ( label) => ( SawExprAgain ( label. map ( |l| l. name . as_str ( ) ) ) , false ) ,
343
343
ExprRet ( ..) => ( SawExprRet , false ) ,
344
- ExprInlineAsm ( ref a, ..) => ( SawExprInlineAsm ( a ) , false ) ,
344
+ ExprInlineAsm ( ref a, ..) => ( SawExprInlineAsm ( StableInlineAsm ( a ) ) , false ) ,
345
345
ExprStruct ( ..) => ( SawExprStruct , false ) ,
346
346
ExprRepeat ( ..) => ( SawExprRepeat , false ) ,
347
347
}
@@ -492,6 +492,46 @@ enum SawSpanExpnKind {
492
492
SomeExpansion ,
493
493
}
494
494
495
+ /// A wrapper that provides a stable Hash implementation.
496
+ struct StableInlineAsm < ' a > ( & ' a InlineAsm ) ;
497
+
498
+ impl < ' a > Hash for StableInlineAsm < ' a > {
499
+ fn hash < H : Hasher > ( & self , state : & mut H ) {
500
+ let InlineAsm {
501
+ asm,
502
+ asm_str_style,
503
+ ref outputs,
504
+ ref inputs,
505
+ ref clobbers,
506
+ volatile,
507
+ alignstack,
508
+ dialect,
509
+ expn_id : _, // This is used for error reporting
510
+ } = * self . 0 ;
511
+
512
+ asm. as_str ( ) . hash ( state) ;
513
+ asm_str_style. hash ( state) ;
514
+ outputs. len ( ) . hash ( state) ;
515
+ for output in outputs {
516
+ let InlineAsmOutput { constraint, is_rw, is_indirect } = * output;
517
+ constraint. as_str ( ) . hash ( state) ;
518
+ is_rw. hash ( state) ;
519
+ is_indirect. hash ( state) ;
520
+ }
521
+ inputs. len ( ) . hash ( state) ;
522
+ for input in inputs {
523
+ input. as_str ( ) . hash ( state) ;
524
+ }
525
+ clobbers. len ( ) . hash ( state) ;
526
+ for clobber in clobbers {
527
+ clobber. as_str ( ) . hash ( state) ;
528
+ }
529
+ volatile. hash ( state) ;
530
+ alignstack. hash ( state) ;
531
+ dialect. hash ( state) ;
532
+ }
533
+ }
534
+
495
535
macro_rules! hash_attrs {
496
536
( $visitor: expr, $attrs: expr) => ( {
497
537
let attrs = $attrs;
0 commit comments