@@ -1926,33 +1926,23 @@ pub mod tls {
1926
1926
1927
1927
/// A thread local variable which stores a pointer to the current ImplicitCtxt
1928
1928
#[ cfg( not( parallel_queries) ) ]
1929
- // Accessing `thread_local` in another crate is bugged, so we have
1930
- // two accessors `set_raw_tlv` and `get_tlv` which do not have an
1931
- // inline attribute to prevent that
1932
- #[ thread_local]
1933
- static TLV : Cell < usize > = Cell :: new ( 0 ) ;
1934
-
1935
- /// This is used to set the pointer to the current ImplicitCtxt.
1936
- #[ cfg( not( parallel_queries) ) ]
1937
- fn set_raw_tlv ( value : usize ) {
1938
- TLV . set ( value)
1939
- }
1929
+ thread_local ! ( static TLV : Cell <usize > = Cell :: new( 0 ) ) ;
1940
1930
1941
1931
/// Sets TLV to `value` during the call to `f`.
1942
1932
/// It is restored to its previous value after.
1943
1933
/// This is used to set the pointer to the new ImplicitCtxt.
1944
1934
#[ cfg( not( parallel_queries) ) ]
1945
1935
fn set_tlv < F : FnOnce ( ) -> R , R > ( value : usize , f : F ) -> R {
1946
1936
let old = get_tlv ( ) ;
1947
- let _reset = OnDrop ( move || set_raw_tlv ( old) ) ;
1948
- set_raw_tlv ( value) ;
1937
+ let _reset = OnDrop ( move || TLV . with ( |tlv| tlv . set ( old) ) ) ;
1938
+ TLV . with ( |tlv| tlv . set ( value) ) ;
1949
1939
f ( )
1950
1940
}
1951
1941
1952
1942
/// This is used to get the pointer to the current ImplicitCtxt.
1953
1943
#[ cfg( not( parallel_queries) ) ]
1954
1944
fn get_tlv ( ) -> usize {
1955
- TLV . get ( )
1945
+ TLV . with ( |tlv| tlv . get ( ) )
1956
1946
}
1957
1947
1958
1948
/// This is a callback from libsyntax as it cannot access the implicit state
0 commit comments