@@ -379,13 +379,13 @@ impl_stable_hash_for!(struct mir::interpret::MemoryPointer {
379379} ) ;
380380
381381enum AllocDiscriminant {
382- Static ,
383- Constant ,
382+ Alloc ,
383+ ExternStatic ,
384384 Function ,
385385}
386386impl_stable_hash_for ! ( enum self :: AllocDiscriminant {
387- Static ,
388- Constant ,
387+ Alloc ,
388+ ExternStatic ,
389389 Function
390390} ) ;
391391
@@ -397,17 +397,23 @@ impl<'a> HashStable<StableHashingContext<'a>> for mir::interpret::AllocId {
397397 ) {
398398 ty:: tls:: with_opt ( |tcx| {
399399 let tcx = tcx. expect ( "can't hash AllocIds during hir lowering" ) ;
400- if let Some ( def_id) = tcx. interpret_interner . get_corresponding_static_def_id ( * self ) {
401- AllocDiscriminant :: Static . hash_stable ( hcx, hasher) ;
402- // statics are unique via their DefId
403- def_id. hash_stable ( hcx, hasher) ;
404- } else if let Some ( alloc) = tcx. interpret_interner . get_alloc ( * self ) {
405- // not a static, can't be recursive, hash the allocation
406- AllocDiscriminant :: Constant . hash_stable ( hcx, hasher) ;
407- alloc. hash_stable ( hcx, hasher) ;
400+ if let Some ( alloc) = tcx. interpret_interner . get_alloc ( * self ) {
401+ AllocDiscriminant :: Alloc . hash_stable ( hcx, hasher) ;
402+ if !hcx. alloc_id_recursion_tracker . insert ( * self ) {
403+ tcx
404+ . interpret_interner
405+ . get_corresponding_static_def_id ( * self )
406+ . hash_stable ( hcx, hasher) ;
407+ alloc. hash_stable ( hcx, hasher) ;
408+ assert ! ( hcx. alloc_id_recursion_tracker. remove( self ) ) ;
409+ }
408410 } else if let Some ( inst) = tcx. interpret_interner . get_fn ( * self ) {
409411 AllocDiscriminant :: Function . hash_stable ( hcx, hasher) ;
410412 inst. hash_stable ( hcx, hasher) ;
413+ } else if let Some ( def_id) = tcx. interpret_interner
414+ . get_corresponding_static_def_id ( * self ) {
415+ AllocDiscriminant :: ExternStatic . hash_stable ( hcx, hasher) ;
416+ def_id. hash_stable ( hcx, hasher) ;
411417 } else {
412418 bug ! ( "no allocation for {}" , self ) ;
413419 }
0 commit comments