@@ -9,24 +9,6 @@ macro_rules! define_handles {
99 ' owned: $( $oty: ident, ) *
1010 ' interned: $( $ity: ident, ) *
1111 ) => {
12- #[ repr( C ) ]
13- #[ allow( non_snake_case) ]
14- pub struct HandleCounters {
15- $( $oty: AtomicUsize , ) *
16- $( $ity: AtomicUsize , ) *
17- }
18-
19- impl HandleCounters {
20- // FIXME(eddyb) use a reference to the `static COUNTERS`, instead of
21- // a wrapper `fn` pointer, once `const fn` can reference `static`s.
22- extern "C" fn get( ) -> & ' static Self {
23- static COUNTERS : HandleCounters = HandleCounters {
24- $( $oty: AtomicUsize :: new( 1 ) , ) *
25- $( $ity: AtomicUsize :: new( 1 ) , ) *
26- } ;
27- & COUNTERS
28- }
29- }
3012
3113 // FIXME(eddyb) generate the definition of `HandleStore` in `server.rs`.
3214 #[ repr( C ) ]
@@ -37,10 +19,22 @@ macro_rules! define_handles {
3719 }
3820
3921 impl <S : server:: Types > HandleStore <S > {
40- pub ( super ) fn new( handle_counters: & ' static HandleCounters ) -> Self {
22+ pub ( super ) fn new( ) -> Self {
23+ // FIXME(eddyb) these counters are server-side, so they don't
24+ // protect against the same proc macro dylib being used with
25+ // multiple servers - however, that's very unlikely, and should
26+ // be protected against through other means (e.g. forcing a
27+ // specific proc macro dylib to always talk to the same server
28+ // that initially loaded it).
4129 HandleStore {
42- $( $oty: handle:: OwnedStore :: new( & handle_counters. $oty) , ) *
43- $( $ity: handle:: InternedStore :: new( & handle_counters. $ity) , ) *
30+ $( $oty: handle:: OwnedStore :: new( {
31+ static COUNTER : AtomicUsize = AtomicUsize :: new( 1 ) ;
32+ & COUNTER
33+ } ) , ) *
34+ $( $ity: handle:: InternedStore :: new( {
35+ static COUNTER : AtomicUsize = AtomicUsize :: new( 1 ) ;
36+ & COUNTER
37+ } ) , ) *
4438 }
4539 }
4640 }
@@ -370,10 +364,6 @@ impl Bridge<'_> {
370364/// and forcing the use of APIs that take/return `S::TokenStream`, server-side.
371365#[ repr( C ) ]
372366pub struct Client < I , O > {
373- // FIXME(eddyb) use a reference to the `static COUNTERS`, instead of
374- // a wrapper `fn` pointer, once `const fn` can reference `static`s.
375- pub ( super ) get_handle_counters : extern "C" fn ( ) -> & ' static HandleCounters ,
376-
377367 pub ( super ) run : extern "C" fn ( Bridge < ' _ > ) -> Buffer ,
378368
379369 pub ( super ) _marker : PhantomData < fn ( I ) -> O > ,
@@ -433,7 +423,6 @@ fn run_client<A: for<'a, 's> DecodeMut<'a, 's, ()>, R: Encode<()>>(
433423impl Client < crate :: TokenStream , crate :: TokenStream > {
434424 pub const fn expand1 ( f : impl Fn ( crate :: TokenStream ) -> crate :: TokenStream + Copy ) -> Self {
435425 Client {
436- get_handle_counters : HandleCounters :: get,
437426 run : super :: selfless_reify:: reify_to_extern_c_fn_hrt_bridge ( move |bridge| {
438427 run_client ( bridge, |input| f ( crate :: TokenStream ( input) ) . 0 )
439428 } ) ,
@@ -447,7 +436,6 @@ impl Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream> {
447436 f : impl Fn ( crate :: TokenStream , crate :: TokenStream ) -> crate :: TokenStream + Copy ,
448437 ) -> Self {
449438 Client {
450- get_handle_counters : HandleCounters :: get,
451439 run : super :: selfless_reify:: reify_to_extern_c_fn_hrt_bridge ( move |bridge| {
452440 run_client ( bridge, |( input, input2) | {
453441 f ( crate :: TokenStream ( input) , crate :: TokenStream ( input2) ) . 0
0 commit comments