@@ -1926,33 +1926,23 @@ pub mod tls {
19261926
19271927 /// A thread local variable which stores a pointer to the current ImplicitCtxt
19281928 #[ 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 ) ) ;
19401930
19411931 /// Sets TLV to `value` during the call to `f`.
19421932 /// It is restored to its previous value after.
19431933 /// This is used to set the pointer to the new ImplicitCtxt.
19441934 #[ cfg( not( parallel_queries) ) ]
19451935 fn set_tlv < F : FnOnce ( ) -> R , R > ( value : usize , f : F ) -> R {
19461936 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) ) ;
19491939 f ( )
19501940 }
19511941
19521942 /// This is used to get the pointer to the current ImplicitCtxt.
19531943 #[ cfg( not( parallel_queries) ) ]
19541944 fn get_tlv ( ) -> usize {
1955- TLV . get ( )
1945+ TLV . with ( |tlv| tlv . get ( ) )
19561946 }
19571947
19581948 /// This is a callback from libsyntax as it cannot access the implicit state
0 commit comments