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