@@ -54,9 +54,8 @@ use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
5454 StableHasher , StableHasherResult ,
5555 StableVec } ;
5656use arena:: SyncDroplessArena ;
57- use rustc_data_structures:: cold_path;
5857use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
59- use rustc_data_structures:: sync:: { Lrc , Lock , WorkerLocal , AtomicCell } ;
58+ use rustc_data_structures:: sync:: { Lrc , Lock , WorkerLocal , AtomicOnce } ;
6059use std:: any:: Any ;
6160use std:: borrow:: Borrow ;
6261use std:: cmp:: Ordering ;
@@ -1067,7 +1066,7 @@ pub struct GlobalCtxt<'tcx> {
10671066
10681067 pub hir_defs : hir:: map:: Definitions ,
10691068
1070- hir_map : AtomicCell < Option < & ' tcx hir_map:: Map < ' tcx > > > ,
1069+ hir_map : AtomicOnce < & ' tcx hir_map:: Map < ' tcx > > ,
10711070
10721071 /// A map from DefPathHash -> DefId. Includes DefIds from the local crate
10731072 /// as well as all upstream crates. Only populated in incremental mode.
@@ -1136,17 +1135,10 @@ impl<'tcx> TyCtxt<'tcx> {
11361135
11371136 #[ inline( always) ]
11381137 pub fn hir ( self ) -> & ' tcx hir_map:: Map < ' tcx > {
1139- let value = self . hir_map . load ( ) ;
1140- if unlikely ! ( value. is_none( ) ) {
1138+ self . hir_map . get_or_init ( || {
11411139 // We can use `with_ignore` here because the hir map does its own tracking
1142- cold_path ( || self . dep_graph . with_ignore ( || {
1143- let map = self . hir_map ( LOCAL_CRATE ) ;
1144- self . hir_map . store ( Some ( map) ) ;
1145- map
1146- } ) )
1147- } else {
1148- value. unwrap ( )
1149- }
1140+ self . dep_graph . with_ignore ( || self . hir_map ( LOCAL_CRATE ) )
1141+ } )
11501142 }
11511143
11521144 pub fn alloc_steal_mir ( self , mir : Body < ' tcx > ) -> & ' tcx Steal < Body < ' tcx > > {
@@ -1335,7 +1327,7 @@ impl<'tcx> TyCtxt<'tcx> {
13351327 extern_prelude : resolutions. extern_prelude ,
13361328 hir_forest,
13371329 hir_defs,
1338- hir_map : AtomicCell :: new ( None ) ,
1330+ hir_map : AtomicOnce :: new ( ) ,
13391331 def_path_hash_to_def_id,
13401332 queries : query:: Queries :: new (
13411333 providers,
0 commit comments