diff options
Diffstat (limited to 'rtic-macros')
| -rw-r--r-- | rtic-macros/CHANGELOG.md | 6 | ||||
| -rw-r--r-- | rtic-macros/Cargo.toml | 2 | ||||
| -rw-r--r-- | rtic-macros/src/codegen/module.rs | 14 |
3 files changed, 17 insertions, 5 deletions
diff --git a/rtic-macros/CHANGELOG.md b/rtic-macros/CHANGELOG.md index d682ab7..3413d8a 100644 --- a/rtic-macros/CHANGELOG.md +++ b/rtic-macros/CHANGELOG.md @@ -7,12 +7,16 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top! ## [Unreleased] +## [v2.0.1] - 2023-07-25 + ### Added -### Changed +- `init` and `idle` can now be externed. ### Fixed +- Support new TAIT syntax requirement. + ## [v2.0.0] - 2023-05-31 - Initial v2 release diff --git a/rtic-macros/Cargo.toml b/rtic-macros/Cargo.toml index 4649850..ade6842 100644 --- a/rtic-macros/Cargo.toml +++ b/rtic-macros/Cargo.toml @@ -22,7 +22,7 @@ name = "rtic-macros" readme = "../README.md" repository = "https://github.com/rtic-rs/rtic" -version = "2.0.0" +version = "2.0.1" [lib] proc-macro = true 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) } } - } )); |
