@@ -54,9 +54,8 @@ use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
54
54
StableHasher , StableHasherResult ,
55
55
StableVec } ;
56
56
use arena:: SyncDroplessArena ;
57
- use rustc_data_structures:: cold_path;
58
57
use 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 } ;
60
59
use std:: any:: Any ;
61
60
use std:: borrow:: Borrow ;
62
61
use std:: cmp:: Ordering ;
@@ -1067,7 +1066,7 @@ pub struct GlobalCtxt<'tcx> {
1067
1066
1068
1067
pub hir_defs : hir:: map:: Definitions ,
1069
1068
1070
- hir_map : AtomicCell < Option < & ' tcx hir_map:: Map < ' tcx > > > ,
1069
+ hir_map : AtomicOnce < & ' tcx hir_map:: Map < ' tcx > > ,
1071
1070
1072
1071
/// A map from DefPathHash -> DefId. Includes DefIds from the local crate
1073
1072
/// as well as all upstream crates. Only populated in incremental mode.
@@ -1136,17 +1135,10 @@ impl<'tcx> TyCtxt<'tcx> {
1136
1135
1137
1136
#[ inline( always) ]
1138
1137
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 ( || {
1141
1139
// 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
+ } )
1150
1142
}
1151
1143
1152
1144
pub fn alloc_steal_mir ( self , mir : Body < ' tcx > ) -> & ' tcx Steal < Body < ' tcx > > {
@@ -1335,7 +1327,7 @@ impl<'tcx> TyCtxt<'tcx> {
1335
1327
extern_prelude : resolutions. extern_prelude ,
1336
1328
hir_forest,
1337
1329
hir_defs,
1338
- hir_map : AtomicCell :: new ( None ) ,
1330
+ hir_map : AtomicOnce :: new ( ) ,
1339
1331
def_path_hash_to_def_id,
1340
1332
queries : query:: Queries :: new (
1341
1333
providers,
0 commit comments