Skip to content

Commit d91a4d0

Browse files
committed
introduce VariadicMethodInfo
1 parent 6db0c29 commit d91a4d0

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/codegen/mod.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ impl From<DerivableTraits> for Vec<&'static str> {
191191
}
192192
}
193193

194+
struct VariadicMethodInfo {
195+
args: Vec<proc_macro2::TokenStream>,
196+
ret: proc_macro2::TokenStream,
197+
exprs: Vec<proc_macro2::TokenStream>,
198+
}
199+
194200
struct CodegenResult<'a> {
195201
items: Vec<proc_macro2::TokenStream>,
196202
dynamic_items: DynamicItems,
@@ -239,14 +245,7 @@ struct CodegenResult<'a> {
239245
/// that name. This lets us give each overload a unique suffix.
240246
overload_counters: HashMap<String, u32>,
241247

242-
variadic_methods: HashMap<
243-
Ident,
244-
(
245-
Vec<proc_macro2::TokenStream>,
246-
proc_macro2::TokenStream,
247-
Vec<proc_macro2::TokenStream>,
248-
),
249-
>,
248+
variadic_methods: HashMap<Ident, VariadicMethodInfo>,
250249
}
251250

252251
impl<'a> CodegenResult<'a> {
@@ -2497,7 +2496,11 @@ impl MethodCodegen for Method {
24972496
*last_arg = quote!(var_args: impl VarArgs);
24982497
result.variadic_methods.insert(
24992498
function_name.clone(),
2500-
(args.to_owned(), ret.clone(), exprs.clone()),
2499+
VariadicMethodInfo {
2500+
args: args.to_owned(),
2501+
ret: ret.clone(),
2502+
exprs: exprs.clone(),
2503+
},
25012504
);
25022505
}
25032506

@@ -4442,7 +4445,9 @@ pub(crate) fn codegen(
44424445
)
44434446
})
44444447
.collect::<Vec<_>>();
4445-
for (name, (args, ret, exprs)) in result.variadic_methods.drain() {
4448+
for (name, VariadicMethodInfo { args, ret, exprs }) in
4449+
result.variadic_methods.drain()
4450+
{
44464451
let call_name = quote::format_ident!("call_{}", name);
44474452
methods.push(quote! {
44484453
unsafe fn #call_name(self, #(#args),*) #ret

0 commit comments

Comments
 (0)