@@ -52,9 +52,8 @@ use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
5252 StableHasher , StableHasherResult ,
5353 StableVec } ;
5454use arena:: SyncDroplessArena ;
55- use rustc_data_structures:: cold_path;
5655use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
57- use rustc_data_structures:: sync:: { Lrc , Lock , WorkerLocal , AtomicCell } ;
56+ use rustc_data_structures:: sync:: { Lrc , Lock , WorkerLocal , AtomicOnce } ;
5857use std:: any:: Any ;
5958use std:: borrow:: Borrow ;
6059use std:: cmp:: Ordering ;
@@ -1022,7 +1021,7 @@ pub struct GlobalCtxt<'tcx> {
10221021
10231022 pub hir_defs : hir:: map:: Definitions ,
10241023
1025- hir_map : AtomicCell < Option < & ' tcx hir_map:: Map < ' tcx > > > ,
1024+ hir_map : AtomicOnce < & ' tcx hir_map:: Map < ' tcx > > ,
10261025
10271026 /// A map from DefPathHash -> DefId. Includes DefIds from the local crate
10281027 /// as well as all upstream crates. Only populated in incremental mode.
@@ -1089,17 +1088,10 @@ impl<'tcx> TyCtxt<'tcx> {
10891088
10901089 #[ inline( always) ]
10911090 pub fn hir ( self ) -> & ' tcx hir_map:: Map < ' tcx > {
1092- let value = self . hir_map . load ( ) ;
1093- if unlikely ! ( value. is_none( ) ) {
1091+ self . hir_map . get_or_init ( || {
10941092 // We can use `with_ignore` here because the hir map does its own tracking
1095- cold_path ( || self . dep_graph . with_ignore ( || {
1096- let map = self . hir_map ( LOCAL_CRATE ) ;
1097- self . hir_map . store ( Some ( map) ) ;
1098- map
1099- } ) )
1100- } else {
1101- value. unwrap ( )
1102- }
1093+ self . dep_graph . with_ignore ( || self . hir_map ( LOCAL_CRATE ) )
1094+ } )
11031095 }
11041096
11051097 pub fn alloc_steal_mir ( self , mir : Body < ' tcx > ) -> & ' tcx Steal < Body < ' tcx > > {
@@ -1281,7 +1273,7 @@ impl<'tcx> TyCtxt<'tcx> {
12811273 extern_prelude : resolutions. extern_prelude ,
12821274 hir_forest,
12831275 hir_defs,
1284- hir_map : AtomicCell :: new ( None ) ,
1276+ hir_map : AtomicOnce :: new ( ) ,
12851277 def_path_hash_to_def_id,
12861278 queries : query:: Queries :: new (
12871279 providers,
0 commit comments