@@ -8,7 +8,7 @@ use rustc_ast::expand::allocator::AllocatorKind;
8
8
use rustc_ast:: { self as ast, * } ;
9
9
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
10
10
use rustc_data_structures:: svh:: Svh ;
11
- use rustc_data_structures:: sync:: MappedReadGuard ;
11
+ use rustc_data_structures:: sync:: { MappedReadGuard , MappedWriteGuard , ReadGuard , WriteGuard } ;
12
12
use rustc_expand:: base:: SyntaxExtension ;
13
13
use rustc_hir:: def_id:: { CrateNum , LocalDefId , StableCrateId , LOCAL_CRATE } ;
14
14
use rustc_hir:: definitions:: Definitions ;
@@ -133,8 +133,14 @@ impl<'a> std::fmt::Debug for CrateDump<'a> {
133
133
134
134
impl CStore {
135
135
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`" )
138
144
} )
139
145
}
140
146
@@ -268,9 +274,6 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
268
274
) -> Self {
269
275
CrateLoader { tcx, cstore, used_extern_options }
270
276
}
271
- pub fn cstore ( & self ) -> & CStore {
272
- & self . cstore
273
- }
274
277
275
278
fn existing_match ( & self , name : Symbol , hash : Option < Svh > , kind : PathKind ) -> Option < CrateNum > {
276
279
for ( cnum, data) in self . cstore . iter_crate_data ( ) {
0 commit comments