@@ -9,24 +9,6 @@ macro_rules! define_handles {
9
9
' owned: $( $oty: ident, ) *
10
10
' interned: $( $ity: ident, ) *
11
11
) => {
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
- }
30
12
31
13
// FIXME(eddyb) generate the definition of `HandleStore` in `server.rs`.
32
14
#[ repr( C ) ]
@@ -37,10 +19,22 @@ macro_rules! define_handles {
37
19
}
38
20
39
21
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).
41
29
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
+ } ) , ) *
44
38
}
45
39
}
46
40
}
@@ -370,10 +364,6 @@ impl Bridge<'_> {
370
364
/// and forcing the use of APIs that take/return `S::TokenStream`, server-side.
371
365
#[ repr( C ) ]
372
366
pub 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
-
377
367
pub ( super ) run : extern "C" fn ( Bridge < ' _ > ) -> Buffer ,
378
368
379
369
pub ( super ) _marker : PhantomData < fn ( I ) -> O > ,
@@ -433,7 +423,6 @@ fn run_client<A: for<'a, 's> DecodeMut<'a, 's, ()>, R: Encode<()>>(
433
423
impl Client < crate :: TokenStream , crate :: TokenStream > {
434
424
pub const fn expand1 ( f : impl Fn ( crate :: TokenStream ) -> crate :: TokenStream + Copy ) -> Self {
435
425
Client {
436
- get_handle_counters : HandleCounters :: get,
437
426
run : super :: selfless_reify:: reify_to_extern_c_fn_hrt_bridge ( move |bridge| {
438
427
run_client ( bridge, |input| f ( crate :: TokenStream ( input) ) . 0 )
439
428
} ) ,
@@ -447,7 +436,6 @@ impl Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream> {
447
436
f : impl Fn ( crate :: TokenStream , crate :: TokenStream ) -> crate :: TokenStream + Copy ,
448
437
) -> Self {
449
438
Client {
450
- get_handle_counters : HandleCounters :: get,
451
439
run : super :: selfless_reify:: reify_to_extern_c_fn_hrt_bridge ( move |bridge| {
452
440
run_client ( bridge, |( input, input2) | {
453
441
f ( crate :: TokenStream ( input) , crate :: TokenStream ( input2) ) . 0
0 commit comments