@@ -50,9 +50,8 @@ use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
5050 StableHasher , StableHasherResult ,
5151 StableVec } ;
5252use arena:: { TypedArena , SyncDroplessArena } ;
53- use rustc_data_structures:: cold_path;
5453use 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 } ;
5655use std:: any:: Any ;
5756use std:: borrow:: Borrow ;
5857use std:: cmp:: Ordering ;
@@ -1031,7 +1030,7 @@ pub struct GlobalCtxt<'tcx> {
10311030
10321031 pub hir_defs : hir:: map:: Definitions ,
10331032
1034- hir_map : AtomicCell < Option < & ' tcx hir_map:: Map < ' tcx > > > ,
1033+ hir_map : AtomicOnce < & ' tcx hir_map:: Map < ' tcx > > ,
10351034
10361035 /// A map from DefPathHash -> DefId. Includes DefIds from the local crate
10371036 /// as well as all upstream crates. Only populated in incremental mode.
@@ -1104,18 +1103,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11041103 }
11051104
11061105 #[ 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 ( || {
11101108 // 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+ } )
11191111 }
11201112
11211113 pub fn alloc_generics ( self , generics : ty:: Generics ) -> & ' gcx ty:: Generics {
@@ -1307,7 +1299,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
13071299 extern_prelude : resolutions. extern_prelude ,
13081300 hir_forest,
13091301 hir_defs,
1310- hir_map : AtomicCell :: new ( None ) ,
1302+ hir_map : AtomicOnce :: new ( ) ,
13111303 def_path_hash_to_def_id,
13121304 queries : query:: Queries :: new (
13131305 providers,
0 commit comments