Fixed new TAIT requirement and release v2.0.1 of RTIC

This commit is contained in:
Emil Fresk 2023-07-25 10:01:51 +02:00
parent 1967058784
commit 0228350ef4
8 changed files with 39 additions and 17 deletions

View file

@ -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

View file

@ -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

View file

@ -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)
}
}
}
));