@@ -12,7 +12,7 @@ pub use crate::*;
1212
1313use rustc_data_structures:: fx:: FxHashMap ;
1414use rustc_data_structures:: stable_hasher:: StableHasher ;
15- use rustc_data_structures:: sync:: { AtomicU32 , Lock , LockGuard , Lrc , MappedLockGuard } ;
15+ use rustc_data_structures:: sync:: { AtomicU32 , Lrc , MappedReadGuard , ReadGuard , RwLock } ;
1616use std:: cmp;
1717use std:: convert:: TryFrom ;
1818use std:: hash:: Hash ;
@@ -168,7 +168,7 @@ pub struct SourceMap {
168168 /// The address space below this value is currently used by the files in the source map.
169169 used_address_space : AtomicU32 ,
170170
171- files : Lock < SourceMapFiles > ,
171+ files : RwLock < SourceMapFiles > ,
172172 file_loader : Box < dyn FileLoader + Sync + Send > ,
173173 // This is used to apply the file path remapping as specified via
174174 // `--remap-path-prefix` to all `SourceFile`s allocated within this `SourceMap`.
@@ -236,8 +236,8 @@ impl SourceMap {
236236
237237 // By returning a `MonotonicVec`, we ensure that consumers cannot invalidate
238238 // any existing indices pointing into `files`.
239- pub fn files ( & self ) -> MappedLockGuard < ' _ , monotonic:: MonotonicVec < Lrc < SourceFile > > > {
240- LockGuard :: map ( self . files . borrow ( ) , |files| & mut files. source_files )
239+ pub fn files ( & self ) -> MappedReadGuard < ' _ , monotonic:: MonotonicVec < Lrc < SourceFile > > > {
240+ ReadGuard :: map ( self . files . borrow ( ) , |files| & files. source_files )
241241 }
242242
243243 pub fn source_file_by_stable_id (
0 commit comments