@@ -52,9 +52,8 @@ use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
52
52
StableHasher , StableHasherResult ,
53
53
StableVec } ;
54
54
use arena:: SyncDroplessArena ;
55
- use rustc_data_structures:: cold_path;
56
55
use 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 } ;
58
57
use std:: any:: Any ;
59
58
use std:: borrow:: Borrow ;
60
59
use std:: cmp:: Ordering ;
@@ -1022,7 +1021,7 @@ pub struct GlobalCtxt<'tcx> {
1022
1021
1023
1022
pub hir_defs : hir:: map:: Definitions ,
1024
1023
1025
- hir_map : AtomicCell < Option < & ' tcx hir_map:: Map < ' tcx > > > ,
1024
+ hir_map : AtomicOnce < & ' tcx hir_map:: Map < ' tcx > > ,
1026
1025
1027
1026
/// A map from DefPathHash -> DefId. Includes DefIds from the local crate
1028
1027
/// as well as all upstream crates. Only populated in incremental mode.
@@ -1089,17 +1088,10 @@ impl<'tcx> TyCtxt<'tcx> {
1089
1088
1090
1089
#[ inline( always) ]
1091
1090
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 ( || {
1094
1092
// 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
+ } )
1103
1095
}
1104
1096
1105
1097
pub fn alloc_steal_mir ( self , mir : Body < ' tcx > ) -> & ' tcx Steal < Body < ' tcx > > {
@@ -1281,7 +1273,7 @@ impl<'tcx> TyCtxt<'tcx> {
1281
1273
extern_prelude : resolutions. extern_prelude ,
1282
1274
hir_forest,
1283
1275
hir_defs,
1284
- hir_map : AtomicCell :: new ( None ) ,
1276
+ hir_map : AtomicOnce :: new ( ) ,
1285
1277
def_path_hash_to_def_id,
1286
1278
queries : query:: Queries :: new (
1287
1279
providers,
0 commit comments