@@ -36,7 +36,7 @@ use rustc_data_structures::profiling::SelfProfilerRef;
3636use rustc_data_structures:: sharded:: { IntoPointer , ShardedHashMap } ;
3737use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
3838use rustc_data_structures:: steal:: Steal ;
39- use rustc_data_structures:: sync:: { self , Lock , Lrc , ReadGuard , WorkerLocal } ;
39+ use rustc_data_structures:: sync:: { self , Lock , Lrc , MappedReadGuard , ReadGuard , WorkerLocal } ;
4040use rustc_errors:: {
4141 DecorateLint , DiagnosticBuilder , DiagnosticMessage , ErrorGuaranteed , MultiSpan ,
4242} ;
@@ -836,7 +836,7 @@ impl<'tcx> TyCtxt<'tcx> {
836836 if let Some ( id) = id. as_local ( ) {
837837 self . definitions_untracked ( ) . def_key ( id)
838838 } else {
839- self . untracked . cstore . def_key ( id)
839+ self . cstore_untracked ( ) . def_key ( id)
840840 }
841841 }
842842
@@ -850,7 +850,7 @@ impl<'tcx> TyCtxt<'tcx> {
850850 if let Some ( id) = id. as_local ( ) {
851851 self . definitions_untracked ( ) . def_path ( id)
852852 } else {
853- self . untracked . cstore . def_path ( id)
853+ self . cstore_untracked ( ) . def_path ( id)
854854 }
855855 }
856856
@@ -860,7 +860,7 @@ impl<'tcx> TyCtxt<'tcx> {
860860 if let Some ( def_id) = def_id. as_local ( ) {
861861 self . definitions_untracked ( ) . def_path_hash ( def_id)
862862 } else {
863- self . untracked . cstore . def_path_hash ( def_id)
863+ self . cstore_untracked ( ) . def_path_hash ( def_id)
864864 }
865865 }
866866
@@ -869,7 +869,7 @@ impl<'tcx> TyCtxt<'tcx> {
869869 if crate_num == LOCAL_CRATE {
870870 self . sess . local_stable_crate_id ( )
871871 } else {
872- self . untracked . cstore . stable_crate_id ( crate_num)
872+ self . cstore_untracked ( ) . stable_crate_id ( crate_num)
873873 }
874874 }
875875
@@ -880,7 +880,7 @@ impl<'tcx> TyCtxt<'tcx> {
880880 if stable_crate_id == self . sess . local_stable_crate_id ( ) {
881881 LOCAL_CRATE
882882 } else {
883- self . untracked . cstore . stable_crate_id_to_crate_num ( stable_crate_id)
883+ self . cstore_untracked ( ) . stable_crate_id_to_crate_num ( stable_crate_id)
884884 }
885885 }
886886
@@ -899,7 +899,7 @@ impl<'tcx> TyCtxt<'tcx> {
899899 } else {
900900 // If this is a DefPathHash from an upstream crate, let the CrateStore map
901901 // it to a DefId.
902- let cstore = & * self . untracked . cstore ;
902+ let cstore = & * self . cstore_untracked ( ) ;
903903 let cnum = cstore. stable_crate_id_to_crate_num ( stable_crate_id) ;
904904 cstore. def_path_hash_to_def_id ( cnum, hash)
905905 }
@@ -913,7 +913,7 @@ impl<'tcx> TyCtxt<'tcx> {
913913 let ( crate_name, stable_crate_id) = if def_id. is_local ( ) {
914914 ( self . crate_name ( LOCAL_CRATE ) , self . sess . local_stable_crate_id ( ) )
915915 } else {
916- let cstore = & * self . untracked . cstore ;
916+ let cstore = & * self . cstore_untracked ( ) ;
917917 ( cstore. crate_name ( def_id. krate ) , cstore. stable_crate_id ( def_id. krate ) )
918918 } ;
919919
@@ -1011,8 +1011,8 @@ impl<'tcx> TyCtxt<'tcx> {
10111011
10121012 /// Note that this is *untracked* and should only be used within the query
10131013 /// system if the result is otherwise tracked through queries
1014- pub fn cstore_untracked ( self ) -> & ' tcx CrateStoreDyn {
1015- & * self . untracked . cstore
1014+ pub fn cstore_untracked ( self ) -> MappedReadGuard < ' tcx , CrateStoreDyn > {
1015+ ReadGuard :: map ( self . untracked . cstore . read ( ) , |c| & * * c )
10161016 }
10171017
10181018 /// Note that this is *untracked* and should only be used within the query
0 commit comments