@@ -2,7 +2,7 @@ use crate::syntax::{ast::App, Context};
22use crate :: { analyze:: Analysis , codegen:: bindings:: interrupt_mod, codegen:: util} ;
33
44use proc_macro2:: TokenStream as TokenStream2 ;
5- use quote:: { format_ident , quote} ;
5+ use quote:: quote;
66
77#[ allow( clippy:: too_many_lines) ]
88pub fn codegen ( ctxt : Context , app : & App , analysis : & Analysis ) -> TokenStream2 {
@@ -132,19 +132,9 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 {
132132 let internal_spawn_helper_ident = util:: internal_task_ident ( name, "spawn_helper" ) ;
133133 let internal_waker_ident = util:: internal_task_ident ( name, "waker" ) ;
134134 let from_ptr_n_args = util:: from_ptr_n_args_ident ( spawnee. inputs . len ( ) ) ;
135- let ( input_args, input_tupled, input_untupled, input_ty) =
135+ let ( generic_input_args , input_args, input_tupled, input_untupled, input_ty) =
136136 util:: regroup_inputs ( & spawnee. inputs ) ;
137137
138- let generics: Vec < _ > = spawnee. inputs . iter ( ) . enumerate ( ) . map ( |( i, _) | format_ident ! ( "T{i}" ) ) . collect ( ) ;
139- let generic_input_args = generics. iter ( ) . enumerate ( ) . map ( |( i, generic) | {
140- let ident = format_ident ! ( "_{i}" ) ;
141- quote ! { #ident: #generic }
142- } ) ;
143- let constraints = generics. iter ( ) . zip ( & spawnee. inputs ) . map ( |( generic, input) | {
144- let ty = & input. ty ;
145- quote ! { #generic: rtic:: export:: dummy:: Dummy <T =#ty> + Send + Sync }
146- } ) ;
147-
148138 // Spawn caller
149139 items. push ( quote ! (
150140 #( #cfgs) *
@@ -171,9 +161,8 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 {
171161 /// Spawns the task directly
172162 #[ allow( non_snake_case) ]
173163 #[ doc( hidden) ]
174- pub fn #internal_spawn_ident<#( #generics) , * >( #( #generic_input_args, ) * ) -> :: core:: result:: Result <( ) , #input_ty>
175- where #( #constraints) , *
176- {
164+ pub fn #internal_spawn_ident( #( #generic_input_args, ) * ) -> :: core:: result:: Result <( ) , #input_ty> {
165+ // SAFETY: The generic args require Send + Sync
177166 unsafe { #internal_spawn_helper_ident( #( #input_untupled. to( ) ) , * ) }
178167 }
179168 ) ) ;
@@ -224,27 +213,21 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 {
224213 let internal_spawn_ident = util:: internal_task_ident ( ident, "spawn_helper" ) ;
225214 let attrs = & task. attrs ;
226215 let cfgs = & task. cfgs ;
227- let inputs = & task. inputs ;
228216 let generics = if task. is_bottom {
229217 quote ! ( )
230218 } else {
231219 quote ! ( <' a>)
232220 } ;
233221
234- let input_vals = inputs. iter ( ) . map ( |i| match & * i. pat {
235- syn:: Pat :: Ident ( pat_ident) => pat_ident. ident . clone ( ) ,
236- _ => todo ! ( ) ,
237- } ) . collect :: < Vec < _ > > ( ) ;
238-
239- let ( _input_args, _input_tupled, _input_untupled, input_ty) = util:: regroup_inputs ( & task. inputs ) ;
222+ let ( _generic_input_args, input_args, _input_tupled, input_untupled, input_ty) = util:: regroup_inputs ( & task. inputs ) ;
240223 quote ! {
241224 #( #attrs) *
242225 #( #cfgs) *
243226 #[ allow( non_snake_case) ]
244- pub ( super ) fn #ident #generics( & self #( , #[ allow ( unused_mut ) ] #inputs ) * ) -> :: core:: result:: Result <( ) , #input_ty> {
227+ pub ( super ) fn #ident #generics( & self #( , #input_args ) * ) -> :: core:: result:: Result <( ) , #input_ty> {
245228 // SAFETY: This is safe to call since this can only be called
246229 // from the same executor
247- unsafe { #internal_spawn_ident( #( #input_vals , ) * ) }
230+ unsafe { #internal_spawn_ident( #( #input_untupled , ) * ) }
248231 }
249232 }
250233 } )
0 commit comments