@@ -28,7 +28,7 @@ use rustc::hir::def_id::DefId;
2828use rustc:: hir:: intravisit as visit;
2929use rustc:: ty:: TyCtxt ;
3030use rustc_data_structures:: fnv;
31- use std:: hash:: Hash ;
31+ use std:: hash:: { Hash , Hasher } ;
3232
3333use super :: def_path_hash:: DefPathHashes ;
3434use super :: caching_codemap_view:: CachingCodemapView ;
@@ -264,7 +264,7 @@ enum SawExprComponent<'a> {
264264 SawExprPath ,
265265 SawExprAddrOf ( hir:: Mutability ) ,
266266 SawExprRet ,
267- SawExprInlineAsm ( & ' a hir :: InlineAsm ) ,
267+ SawExprInlineAsm ( StableInlineAsm < ' a > ) ,
268268 SawExprStruct ,
269269 SawExprRepeat ,
270270}
@@ -340,7 +340,7 @@ fn saw_expr<'a>(node: &'a Expr_,
340340 ExprBreak ( label, _) => ( SawExprBreak ( label. map ( |l| l. name . as_str ( ) ) ) , false ) ,
341341 ExprAgain ( label) => ( SawExprAgain ( label. map ( |l| l. name . as_str ( ) ) ) , false ) ,
342342 ExprRet ( ..) => ( SawExprRet , false ) ,
343- ExprInlineAsm ( ref a, ..) => ( SawExprInlineAsm ( a ) , false ) ,
343+ ExprInlineAsm ( ref a, ..) => ( SawExprInlineAsm ( StableInlineAsm ( a ) ) , false ) ,
344344 ExprStruct ( ..) => ( SawExprStruct , false ) ,
345345 ExprRepeat ( ..) => ( SawExprRepeat , false ) ,
346346 }
@@ -491,6 +491,46 @@ enum SawSpanExpnKind {
491491 SomeExpansion ,
492492}
493493
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+
494534macro_rules! hash_attrs {
495535 ( $visitor: expr, $attrs: expr) => ( {
496536 let attrs = $attrs;
0 commit comments