From 355b478c4343feca55480989c56c506ebad644ee Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Sun, 19 Oct 2025 13:41:03 +0200 Subject: [PATCH] Add passing test for local task with non Send/Sync arg Ensure it is possible to pass a non send and non Sync argument when spawning a local task. This is ok since it will only be possible to spawn the task on the same executor and priority level --- rtic-macros/ui/spawn-local-no-send-sync.rs | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 rtic-macros/ui/spawn-local-no-send-sync.rs diff --git a/rtic-macros/ui/spawn-local-no-send-sync.rs b/rtic-macros/ui/spawn-local-no-send-sync.rs new file mode 100644 index 00000000000..6295b86d005 --- /dev/null +++ b/rtic-macros/ui/spawn-local-no-send-sync.rs @@ -0,0 +1,29 @@ +#![no_main] + +#[rtic_macros::mock_app(device = mock, dispatchers = [EXTI0])] +mod app { + use super::*; + + #[shared] + struct Shared {} + + #[local] + struct Local {} + + #[init] + fn init(_cx: init::Context) -> (Shared, Local) { + task1::spawn().ok(); + (Shared {}, Local {}) + } + + #[task(priority = 1)] + async fn task1(cx: task1::Context) { + cx.local_spawner.task2(Default::default()).ok(); + } + + #[task(priority = 1, is_local_task = true)] + async fn task2(_cx: task2::Context, _nsns: super::NotSendNotSync) {} +} + +#[derive(Default)] +struct NotSendNotSync(PhantomData<*mut u8>); \ No newline at end of file