File tree 2 files changed +12
-10
lines changed
2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ use {BytePos, SpanData};
18
18
use hygiene:: SyntaxContext ;
19
19
20
20
use rustc_data_structures:: fx:: FxHashMap ;
21
- use std :: cell :: RefCell ;
21
+ use rustc_data_structures :: sync :: Lock ;
22
22
23
23
/// A compressed span.
24
24
/// Contains either fields of `SpanData` inline if they are small, or index into span interner.
@@ -135,11 +135,11 @@ impl SpanInterner {
135
135
}
136
136
}
137
137
138
- // If an interner exists in TLS , return it. Otherwise, prepare a fresh one.
138
+ // If an interner exists, return it. Otherwise, prepare a fresh one.
139
139
#[ inline]
140
140
fn with_span_interner < T , F : FnOnce ( & mut SpanInterner ) -> T > ( f : F ) -> T {
141
- thread_local ! ( static INTERNER : RefCell <SpanInterner > = {
142
- RefCell :: new( SpanInterner :: default ( ) )
141
+ rustc_global ! ( static INTERNER : Lock <SpanInterner > = {
142
+ Lock :: new( SpanInterner :: default ( ) )
143
143
} ) ;
144
- INTERNER . with ( |interner| f ( & mut * interner. borrow_mut ( ) ) )
144
+ rustc_access_global ! ( INTERNER , |interner| f( & mut * interner. lock ( ) ) )
145
145
}
Original file line number Diff line number Diff line change 14
14
15
15
use hygiene:: SyntaxContext ;
16
16
17
+ use rustc_data_structures:: sync:: Lock ;
17
18
use serialize:: { Decodable , Decoder , Encodable , Encoder } ;
18
- use std:: cell:: RefCell ;
19
19
use std:: collections:: HashMap ;
20
20
use std:: fmt;
21
21
@@ -326,12 +326,14 @@ declare_keywords! {
326
326
( 60 , Union , "union" )
327
327
}
328
328
329
- // If an interner exists in TLS, return it. Otherwise, prepare a fresh one.
329
+
330
+ // If an interner exists, return it. Otherwise, prepare a fresh one.
331
+ #[ inline]
330
332
fn with_interner < T , F : FnOnce ( & mut Interner ) -> T > ( f : F ) -> T {
331
- thread_local ! ( static INTERNER : RefCell <Interner > = {
332
- RefCell :: new( Interner :: fresh( ) )
333
+ rustc_global ! ( static INTERNER : Lock <Interner > = {
334
+ Lock :: new( Interner :: fresh( ) )
333
335
} ) ;
334
- INTERNER . with ( |interner| f ( & mut * interner. borrow_mut ( ) ) )
336
+ rustc_access_global ! ( INTERNER , |interner| f( & mut * interner. lock ( ) ) )
335
337
}
336
338
337
339
/// Represents a string stored in the thread-local interner. Because the
You can’t perform that action at this time.
0 commit comments