@@ -8,7 +8,7 @@ use rustc_ast::expand::allocator::AllocatorKind;
88use rustc_ast:: { self as ast, * } ;
99use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
1010use rustc_data_structures:: svh:: Svh ;
11- use rustc_data_structures:: sync:: MappedReadGuard ;
11+ use rustc_data_structures:: sync:: { MappedReadGuard , MappedWriteGuard , ReadGuard , WriteGuard } ;
1212use rustc_expand:: base:: SyntaxExtension ;
1313use rustc_hir:: def_id:: { CrateNum , LocalDefId , StableCrateId , LOCAL_CRATE } ;
1414use rustc_hir:: definitions:: Definitions ;
@@ -133,8 +133,14 @@ impl<'a> std::fmt::Debug for CrateDump<'a> {
133133
134134impl CStore {
135135 pub fn from_tcx ( tcx : TyCtxt < ' _ > ) -> MappedReadGuard < ' _ , CStore > {
136- MappedReadGuard :: map ( tcx. cstore_untracked ( ) , |c| {
137- c. as_any ( ) . downcast_ref :: < CStore > ( ) . expect ( "`tcx.cstore` is not a `CStore`" )
136+ ReadGuard :: map ( tcx. untracked ( ) . cstore . read ( ) , |cstore| {
137+ cstore. as_any ( ) . downcast_ref :: < CStore > ( ) . expect ( "`tcx.cstore` is not a `CStore`" )
138+ } )
139+ }
140+
141+ pub fn from_tcx_mut ( tcx : TyCtxt < ' _ > ) -> MappedWriteGuard < ' _ , CStore > {
142+ WriteGuard :: map ( tcx. untracked ( ) . cstore . write ( ) , |cstore| {
143+ cstore. untracked_as_any ( ) . downcast_mut ( ) . expect ( "`tcx.cstore` is not a `CStore`" )
138144 } )
139145 }
140146
@@ -268,9 +274,6 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
268274 ) -> Self {
269275 CrateLoader { tcx, cstore, used_extern_options }
270276 }
271- pub fn cstore ( & self ) -> & CStore {
272- & self . cstore
273- }
274277
275278 fn existing_match ( & self , name : Symbol , hash : Option < Svh > , kind : PathKind ) -> Option < CrateNum > {
276279 for ( cnum, data) in self . cstore . iter_crate_data ( ) {
0 commit comments