From 4cd8d88f30dd61486bf821b956a3e189643ee7cb Mon Sep 17 00:00:00 2001 From: SOFe Date: Sat, 3 Feb 2024 18:27:36 +0800 Subject: [PATCH] fix(codegen): #[system] should copy attributes to generated functions too --- codegen/src/lib.rs | 1 + codegen/src/system.rs | 3 ++- codegen/src/tracer_def.rs | 2 +- rust-toolchain | 2 +- src/entity/ealloc/recycling.rs | 20 +++++++++++--------- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index b705eb8c16..536a756184 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -1,4 +1,5 @@ #![feature(extract_if)] +#![allow(dead_code)] use proc_macro::TokenStream; diff --git a/codegen/src/system.rs b/codegen/src/system.rs index 0e91743eff..b36c56b6e3 100644 --- a/codegen/src/system.rs +++ b/codegen/src/system.rs @@ -22,7 +22,6 @@ pub(crate) fn imp(args: TokenStream, input: TokenStream) -> Result return Err(Error::new_spanned(&input.sig.output, "system functions must return unit")); } - // 1. Parse item-level attributes. let item = item::Agg::parse(ident, args)?; let item::Agg { crate_name, name, state_maybe_uninit, deps, .. } = item; @@ -384,6 +383,7 @@ pub(crate) fn imp(args: TokenStream, input: TokenStream) -> Result #[automatically_derived] impl #ident { #build_fn + #[allow(clippy::too_many_arguments)] #call_fn } @@ -393,6 +393,7 @@ pub(crate) fn imp(args: TokenStream, input: TokenStream) -> Result #impl_referrer_for_local_state // The actual function is moved here. + #(#other_attrs)* fn __dynec_original(#(#input_args),*) { #fn_body } diff --git a/codegen/src/tracer_def.rs b/codegen/src/tracer_def.rs index 6410487412..e7c22b05d8 100644 --- a/codegen/src/tracer_def.rs +++ b/codegen/src/tracer_def.rs @@ -315,7 +315,7 @@ impl Parse for Named { } } -#[allow(clippy::enum_variant_names)] // TODO remove this when we add more implementations +#[allow(clippy::enum_variant_names)] enum AssocFnParamOpt { LogSkip, LogElapsedDuration, diff --git a/rust-toolchain b/rust-toolchain index 3882c635e0..f424055c51 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2023-11-21 +nightly-2024-01-31 diff --git a/src/entity/ealloc/recycling.rs b/src/entity/ealloc/recycling.rs index 8e30defe59..3b4011f3f2 100644 --- a/src/entity/ealloc/recycling.rs +++ b/src/entity/ealloc/recycling.rs @@ -2,7 +2,8 @@ use std::collections::BTreeSet; use std::sync::Arc; use std::{iter, ops}; -use parking_lot::Mutex; +use parking_lot::lock_api::ArcMutexGuard; +use parking_lot::{Mutex, RawMutex}; use super::{iter_gaps, Ealloc, Shard, ShardAssigner, Snapshot}; use crate::entity::raw::Atomic; @@ -72,7 +73,11 @@ impl, S: ShardAssigner> Recycling { impl, S: ShardAssigner> Ealloc for Recycling { type Raw = RawT; type AllocHint = T::Hint; - type Shard = impl Shard; + type Shard = RecyclingShard< + Arc, + ArcMutexGuard, + ArcMutexGuard>, + >; fn new(num_shards: usize) -> Self { Self::new_with_shard_assigner(num_shards, S::default()) } @@ -81,13 +86,10 @@ impl, S: ShardAssigner> Ealloc for Recycling Self::Shard { - // The return type hint here is used to constrain the TAIT, don't delete it. - RecyclingShard { - global_gauge: Arc::clone(&self.global_gauge), - recycler: Arc::clone(recycler).lock_arc(), - reuse_queue: Arc::clone(reuse_queue).lock_arc(), - } + .map(|(recycler, reuse_queue)| RecyclingShard { + global_gauge: Arc::clone(&self.global_gauge), + recycler: Arc::clone(recycler).lock_arc(), + reuse_queue: Arc::clone(reuse_queue).lock_arc(), }) .map(f), );