diff options
| author | Emil Fresk <emil.fresk@gmail.com> | 2023-07-25 10:01:51 +0200 |
|---|---|---|
| committer | Emil Fresk <emil.fresk@gmail.com> | 2023-07-25 08:16:13 +0000 |
| commit | 0228350ef4758c45623e325c41116720bbc2b30a (patch) | |
| tree | 31ef9889d6332e64ec624c4047af284c82ac7a45 /rtic-macros/src/codegen/module.rs | |
| parent | 1967058784ae674b69302500f4b95c1fc4ab4056 (diff) | |
Fixed new TAIT requirement and release v2.0.1 of RTIC
Diffstat (limited to 'rtic-macros/src/codegen/module.rs')
| -rw-r--r-- | rtic-macros/src/codegen/module.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/rtic-macros/src/codegen/module.rs b/rtic-macros/src/codegen/module.rs index cf066ef..7d3ac54 100644 --- a/rtic-macros/src/codegen/module.rs +++ b/rtic-macros/src/codegen/module.rs @@ -150,6 +150,8 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 { let (input_args, input_tupled, input_untupled, input_ty) = util::regroup_inputs(&spawnee.inputs); + let type_name = util::internal_task_ident(name, "F"); + // Spawn caller items.push(quote!( #(#cfgs)* @@ -157,10 +159,17 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 { #[allow(non_snake_case)] #[doc(hidden)] pub fn #internal_spawn_ident(#(#input_args,)*) -> Result<(), #input_ty> { - // SAFETY: If `try_allocate` suceeds one must call `spawn`, which we do. + // New TAIT requirement hack; the opaque type must be in the argument or return + // position of a function... + #[inline(always)] + fn tait_hack(#(#input_args,)*) -> #type_name { + #name(unsafe { #name::Context::new() } #(,#input_untupled)*) + } + + // SAFETY: If `try_allocate` succeeds one must call `spawn`, which we do. unsafe { if #exec_name.try_allocate() { - let f = #name(unsafe { #name::Context::new() } #(,#input_untupled)*); + let f = tait_hack(#(#input_untupled,)*); #exec_name.spawn(f); #pend_interrupt @@ -169,7 +178,6 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 { Err(#input_tupled) } } - } )); |
