@@ -664,7 +664,21 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for ExpnId {
664
664
665
665
let data: ExpnData = decoder
666
666
. with_position ( pos. to_usize ( ) , |decoder| decode_tagged ( decoder, TAG_EXPN_DATA ) ) ?;
667
- rustc_span:: hygiene:: register_local_expn_id ( data, hash)
667
+ let expn_id = rustc_span:: hygiene:: register_local_expn_id ( data, hash) ;
668
+
669
+ #[ cfg( debug_assertions) ]
670
+ {
671
+ use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
672
+ let mut hcx = decoder. tcx . create_stable_hashing_context ( ) ;
673
+ let mut hasher = StableHasher :: new ( ) ;
674
+ hcx. while_hashing_spans ( true , |hcx| {
675
+ expn_id. expn_data ( ) . hash_stable ( hcx, & mut hasher)
676
+ } ) ;
677
+ let local_hash: u64 = hasher. finish ( ) ;
678
+ debug_assert_eq ! ( hash. local_hash( ) , local_hash) ;
679
+ }
680
+
681
+ expn_id
668
682
} else {
669
683
let index_guess = decoder. foreign_expn_data [ & hash] ;
670
684
decoder. tcx . cstore_untracked ( ) . expn_hash_to_expn_id (
@@ -675,16 +689,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for ExpnId {
675
689
)
676
690
} ;
677
691
678
- #[ cfg( debug_assertions) ]
679
- {
680
- use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
681
- let mut hcx = decoder. tcx . create_stable_hashing_context ( ) ;
682
- let mut hasher = StableHasher :: new ( ) ;
683
- hcx. while_hashing_spans ( true , |hcx| expn_id. expn_data ( ) . hash_stable ( hcx, & mut hasher) ) ;
684
- let local_hash: u64 = hasher. finish ( ) ;
685
- debug_assert_eq ! ( hash. local_hash( ) , local_hash) ;
686
- }
687
-
692
+ debug_assert_eq ! ( expn_id. krate, krate) ;
688
693
Ok ( expn_id)
689
694
}
690
695
}
0 commit comments