27
27
use self :: TargetLint :: * ;
28
28
29
29
use std:: slice;
30
+ use rustc_data_structures:: sync:: { RwLock , ReadGuard } ;
30
31
use lint:: { EarlyLintPassObject , LateLintPassObject } ;
31
32
use lint:: { Level , Lint , LintId , LintPass , LintBuffer } ;
32
33
use lint:: builtin:: BuiltinLintDiagnostics ;
@@ -39,7 +40,6 @@ use ty::layout::{LayoutError, LayoutOf, TyLayout};
39
40
use util:: nodemap:: FxHashMap ;
40
41
41
42
use std:: default:: Default as StdDefault ;
42
- use std:: cell:: { Ref , RefCell } ;
43
43
use syntax:: ast;
44
44
use syntax:: edition;
45
45
use syntax_pos:: { MultiSpan , Span } ;
@@ -78,7 +78,7 @@ pub struct LintStore {
78
78
79
79
pub struct LintSession < ' a , PassObject > {
80
80
/// Reference to the store of registered lints.
81
- lints : Ref < ' a , LintStore > ,
81
+ lints : ReadGuard < ' a , LintStore > ,
82
82
83
83
/// Trait objects for each lint pass.
84
84
passes : Option < Vec < PassObject > > ,
@@ -336,7 +336,7 @@ impl<'a, PassObject: LintPassObject> LintSession<'a, PassObject> {
336
336
/// Creates a new `LintSession`, by moving out the `LintStore`'s initial
337
337
/// lint levels and pass objects. These can be restored using the `restore`
338
338
/// method.
339
- fn new ( store : & ' a RefCell < LintStore > ) -> LintSession < ' a , PassObject > {
339
+ fn new ( store : & ' a RwLock < LintStore > ) -> LintSession < ' a , PassObject > {
340
340
let mut s = store. borrow_mut ( ) ;
341
341
let passes = PassObject :: take_passes ( & mut * s) ;
342
342
drop ( s) ;
@@ -347,7 +347,7 @@ impl<'a, PassObject: LintPassObject> LintSession<'a, PassObject> {
347
347
}
348
348
349
349
/// Restores the levels back to the original lint store.
350
- fn restore ( self , store : & RefCell < LintStore > ) {
350
+ fn restore ( self , store : & RwLock < LintStore > ) {
351
351
drop ( self . lints ) ;
352
352
let mut s = store. borrow_mut ( ) ;
353
353
PassObject :: restore_passes ( & mut * s, self . passes ) ;
0 commit comments