Skip to content

Commit f4219cf

Browse files
committed
inline the usage of COUNTERS
1 parent 1cc575d commit f4219cf

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

library/proc_macro/src/bridge/client.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ macro_rules! define_client_handles {
1818
$(pub(super) $ity: AtomicU32,)*
1919
}
2020

21-
static COUNTERS: HandleCounters = HandleCounters {
21+
pub(super) static COUNTERS: HandleCounters = HandleCounters {
2222
$($oty: AtomicU32::new(1),)*
2323
$($ity: AtomicU32::new(1),)*
2424
};
@@ -241,8 +241,6 @@ pub(crate) fn is_available() -> bool {
241241
/// and forcing the use of APIs that take/return `S::TokenStream`, server-side.
242242
#[repr(C)]
243243
pub struct Client<I, O> {
244-
pub(super) handle_counters: &'static HandleCounters,
245-
246244
pub(super) run: extern "C" fn(BridgeConfig<'_>) -> Buffer,
247245

248246
pub(super) _marker: PhantomData<fn(I) -> O>,
@@ -326,7 +324,6 @@ fn run_client<A: for<'a, 's> Decode<'a, 's, ()>, R: Encode<()>>(
326324
impl Client<crate::TokenStream, crate::TokenStream> {
327325
pub const fn expand1(f: impl Fn(crate::TokenStream) -> crate::TokenStream + Copy) -> Self {
328326
Client {
329-
handle_counters: &COUNTERS,
330327
run: super::selfless_reify::reify_to_extern_c_fn_hrt_bridge(move |bridge| {
331328
run_client(bridge, |input| f(crate::TokenStream(Some(input))).0)
332329
}),
@@ -340,7 +337,6 @@ impl Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream> {
340337
f: impl Fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream + Copy,
341338
) -> Self {
342339
Client {
343-
handle_counters: &COUNTERS,
344340
run: super::selfless_reify::reify_to_extern_c_fn_hrt_bridge(move |bridge| {
345341
run_client(bridge, |(input, input2)| {
346342
f(crate::TokenStream(Some(input)), crate::TokenStream(Some(input2))).0

library/proc_macro/src/bridge/server.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ macro_rules! define_server_handles {
1717
}
1818

1919
impl<S: Types> HandleStore<S> {
20-
fn new(handle_counters: &'static client::HandleCounters) -> Self {
20+
fn new() -> Self {
21+
use super::client::COUNTERS;
2122
HandleStore {
22-
$($oty: handle::OwnedStore::new(&handle_counters.$oty),)*
23-
$($ity: handle::InternedStore::new(&handle_counters.$ity),)*
23+
$($oty: handle::OwnedStore::new(&COUNTERS.$oty),)*
24+
$($ity: handle::InternedStore::new(&COUNTERS.$ity),)*
2425
}
2526
}
2627
}
@@ -32,7 +33,7 @@ macro_rules! define_server_handles {
3233
}
3334
}
3435

35-
impl<S: Types> DecodeMut<'_, '_, HandleStore<MarkedTypes<S>>>
36+
impl<S: Types> Decode<'_, '_, HandleStore<MarkedTypes<S>>>
3637
for Marked<S::$oty, client::$oty>
3738
{
3839
fn decode(r: &mut Reader<'_>, s: &mut HandleStore<MarkedTypes<S>>) -> Self {
@@ -358,14 +359,13 @@ fn run_server<
358359
O: for<'a, 's> Decode<'a, 's, HandleStore<MarkedTypes<S>>>,
359360
>(
360361
strategy: &impl ExecutionStrategy,
361-
handle_counters: &'static client::HandleCounters,
362362
server: S,
363363
input: I,
364364
run_client: extern "C" fn(BridgeConfig<'_>) -> Buffer,
365365
force_show_panics: bool,
366366
) -> Result<O, PanicMessage> {
367367
let mut dispatcher =
368-
Dispatcher { handle_store: HandleStore::new(handle_counters), server: MarkedTypes(server) };
368+
Dispatcher { handle_store: HandleStore::new(), server: MarkedTypes(server) };
369369

370370
let globals = dispatcher.server.globals();
371371

@@ -389,10 +389,9 @@ impl client::Client<crate::TokenStream, crate::TokenStream> {
389389
S: Server,
390390
S::TokenStream: Default,
391391
{
392-
let client::Client { handle_counters, run, _marker } = *self;
392+
let client::Client { run, _marker } = *self;
393393
run_server(
394394
strategy,
395-
handle_counters,
396395
server,
397396
<MarkedTypes<S> as Types>::TokenStream::mark(input),
398397
run,
@@ -415,10 +414,9 @@ impl client::Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream
415414
S: Server,
416415
S::TokenStream: Default,
417416
{
418-
let client::Client { handle_counters, run, _marker } = *self;
417+
let client::Client { run, _marker } = *self;
419418
run_server(
420419
strategy,
421-
handle_counters,
422420
server,
423421
(
424422
<MarkedTypes<S> as Types>::TokenStream::mark(input),

0 commit comments

Comments
 (0)