@@ -18,17 +18,10 @@ macro_rules! define_client_handles {
1818 $( pub ( super ) $ity: AtomicU32 , ) *
1919 }
2020
21- impl HandleCounters {
22- // FIXME(eddyb) use a reference to the `static COUNTERS`, instead of
23- // a wrapper `fn` pointer, once `const fn` can reference `static`s.
24- extern "C" fn get( ) -> & ' static Self {
25- static COUNTERS : HandleCounters = HandleCounters {
26- $( $oty: AtomicU32 :: new( 1 ) , ) *
27- $( $ity: AtomicU32 :: new( 1 ) , ) *
28- } ;
29- & COUNTERS
30- }
31- }
21+ static COUNTERS : HandleCounters = HandleCounters {
22+ $( $oty: AtomicU32 :: new( 1 ) , ) *
23+ $( $ity: AtomicU32 :: new( 1 ) , ) *
24+ } ;
3225
3326 $(
3427 pub ( crate ) struct $oty {
@@ -259,9 +252,7 @@ pub(crate) fn is_available() -> bool {
259252/// and forcing the use of APIs that take/return `S::TokenStream`, server-side.
260253#[ repr( C ) ]
261254pub struct Client < I , O > {
262- // FIXME(eddyb) use a reference to the `static COUNTERS`, instead of
263- // a wrapper `fn` pointer, once `const fn` can reference `static`s.
264- pub ( super ) get_handle_counters : extern "C" fn ( ) -> & ' static HandleCounters ,
255+ pub ( super ) handle_counters : & ' static HandleCounters ,
265256
266257 pub ( super ) run : extern "C" fn ( BridgeConfig < ' _ > ) -> Buffer ,
267258
@@ -346,7 +337,7 @@ fn run_client<A: for<'a, 's> DecodeMut<'a, 's, ()>, R: Encode<()>>(
346337impl Client < crate :: TokenStream , crate :: TokenStream > {
347338 pub const fn expand1 ( f : impl Fn ( crate :: TokenStream ) -> crate :: TokenStream + Copy ) -> Self {
348339 Client {
349- get_handle_counters : HandleCounters :: get ,
340+ handle_counters : & COUNTERS ,
350341 run : super :: selfless_reify:: reify_to_extern_c_fn_hrt_bridge ( move |bridge| {
351342 run_client ( bridge, |input| f ( crate :: TokenStream ( Some ( input) ) ) . 0 )
352343 } ) ,
@@ -360,7 +351,7 @@ impl Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream> {
360351 f : impl Fn ( crate :: TokenStream , crate :: TokenStream ) -> crate :: TokenStream + Copy ,
361352 ) -> Self {
362353 Client {
363- get_handle_counters : HandleCounters :: get ,
354+ handle_counters : & COUNTERS ,
364355 run : super :: selfless_reify:: reify_to_extern_c_fn_hrt_bridge ( move |bridge| {
365356 run_client ( bridge, |( input, input2) | {
366357 f ( crate :: TokenStream ( Some ( input) ) , crate :: TokenStream ( Some ( input2) ) ) . 0
0 commit comments