@@ -50,9 +50,8 @@ use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
50
50
StableHasher , StableHasherResult ,
51
51
StableVec } ;
52
52
use arena:: { TypedArena , SyncDroplessArena } ;
53
- use rustc_data_structures:: cold_path;
54
53
use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
55
- use rustc_data_structures:: sync:: { Lrc , Lock , WorkerLocal , AtomicCell } ;
54
+ use rustc_data_structures:: sync:: { Lrc , Lock , WorkerLocal , AtomicOnce } ;
56
55
use std:: any:: Any ;
57
56
use std:: borrow:: Borrow ;
58
57
use std:: cmp:: Ordering ;
@@ -1031,7 +1030,7 @@ pub struct GlobalCtxt<'tcx> {
1031
1030
1032
1031
pub hir_defs : hir:: map:: Definitions ,
1033
1032
1034
- hir_map : AtomicCell < Option < & ' tcx hir_map:: Map < ' tcx > > > ,
1033
+ hir_map : AtomicOnce < & ' tcx hir_map:: Map < ' tcx > > ,
1035
1034
1036
1035
/// A map from DefPathHash -> DefId. Includes DefIds from the local crate
1037
1036
/// as well as all upstream crates. Only populated in incremental mode.
@@ -1104,18 +1103,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1104
1103
}
1105
1104
1106
1105
#[ inline( always) ]
1107
- pub fn hir ( self ) -> & ' a hir_map:: Map < ' gcx > {
1108
- let value = self . hir_map . load ( ) ;
1109
- if unlikely ! ( value. is_none( ) ) {
1106
+ pub fn hir ( self ) -> & ' gcx hir_map:: Map < ' gcx > {
1107
+ self . hir_map . get_or_init ( || {
1110
1108
// We can use `with_ignore` here because the hir map does its own tracking
1111
- cold_path ( || self . dep_graph . with_ignore ( || {
1112
- let map = self . hir_map ( LOCAL_CRATE ) ;
1113
- self . hir_map . store ( Some ( map) ) ;
1114
- map
1115
- } ) )
1116
- } else {
1117
- value. unwrap ( )
1118
- }
1109
+ self . dep_graph . with_ignore ( || self . hir_map ( LOCAL_CRATE ) )
1110
+ } )
1119
1111
}
1120
1112
1121
1113
pub fn alloc_generics ( self , generics : ty:: Generics ) -> & ' gcx ty:: Generics {
@@ -1307,7 +1299,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1307
1299
extern_prelude : resolutions. extern_prelude ,
1308
1300
hir_forest,
1309
1301
hir_defs,
1310
- hir_map : AtomicCell :: new ( None ) ,
1302
+ hir_map : AtomicOnce :: new ( ) ,
1311
1303
def_path_hash_to_def_id,
1312
1304
queries : query:: Queries :: new (
1313
1305
providers,
0 commit comments