From 8aec341f28a00012e1771d5c35d2647e11830755 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 9 Jul 2025 01:49:31 +0200 Subject: executor: return error when creating the spawntoken, not when spawning. --- embassy-executor/tests/ui/return_impl_future_nonsend.rs | 2 +- embassy-executor/tests/ui/return_impl_future_nonsend.stderr | 6 +++--- embassy-executor/tests/ui/return_impl_send.stderr | 2 +- embassy-executor/tests/ui/spawn_nonsend.rs | 2 +- embassy-executor/tests/ui/spawn_nonsend.stderr | 10 +++++----- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'embassy-executor/tests/ui') diff --git a/embassy-executor/tests/ui/return_impl_future_nonsend.rs b/embassy-executor/tests/ui/return_impl_future_nonsend.rs index b8c184b21..77b3119d6 100644 --- a/embassy-executor/tests/ui/return_impl_future_nonsend.rs +++ b/embassy-executor/tests/ui/return_impl_future_nonsend.rs @@ -15,7 +15,7 @@ fn task() -> impl Future { } fn send_spawn(s: SendSpawner) { - s.spawn(task()).unwrap(); + s.spawn(task().unwrap()); } fn main() {} diff --git a/embassy-executor/tests/ui/return_impl_future_nonsend.stderr b/embassy-executor/tests/ui/return_impl_future_nonsend.stderr index 8aeb9738a..51944ad65 100644 --- a/embassy-executor/tests/ui/return_impl_future_nonsend.stderr +++ b/embassy-executor/tests/ui/return_impl_future_nonsend.stderr @@ -1,8 +1,8 @@ error: future cannot be sent between threads safely --> tests/ui/return_impl_future_nonsend.rs:18:13 | -18 | s.spawn(task()).unwrap(); - | ^^^^^^ future created by async block is not `Send` +18 | s.spawn(task().unwrap()); + | ^^^^^^^^^^^^^^^ future created by async block is not `Send` | = help: within `impl Sized`, the trait `Send` is not implemented for `*mut ()` note: captured value is not `Send` @@ -13,5 +13,5 @@ note: captured value is not `Send` note: required by a bound in `SendSpawner::spawn` --> src/spawner.rs | - | pub fn spawn(&self, token: SpawnToken) -> Result<(), SpawnError> { + | pub fn spawn(&self, token: SpawnToken) { | ^^^^ required by this bound in `SendSpawner::spawn` diff --git a/embassy-executor/tests/ui/return_impl_send.stderr b/embassy-executor/tests/ui/return_impl_send.stderr index 759be1cde..5d19465ec 100644 --- a/embassy-executor/tests/ui/return_impl_send.stderr +++ b/embassy-executor/tests/ui/return_impl_send.stderr @@ -97,7 +97,7 @@ note: required by a bound in `TaskPool::::spawn` | impl TaskPool { | ^^^^^^ required by this bound in `TaskPool::::spawn` ... - | pub fn spawn(&'static self, future: impl FnOnce() -> F) -> SpawnToken { + | pub fn spawn(&'static self, future: impl FnOnce() -> F) -> Result, SpawnError> { | ----- required by a bound in this associated function = note: this error originates in the attribute macro `embassy_executor::task` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/embassy-executor/tests/ui/spawn_nonsend.rs b/embassy-executor/tests/ui/spawn_nonsend.rs index 4c4cc7697..601041941 100644 --- a/embassy-executor/tests/ui/spawn_nonsend.rs +++ b/embassy-executor/tests/ui/spawn_nonsend.rs @@ -10,7 +10,7 @@ async fn task(non_send: *mut ()) { } fn send_spawn(s: SendSpawner) { - s.spawn(task(core::ptr::null_mut())).unwrap(); + s.spawn(task(core::ptr::null_mut()).unwrap()); } fn main() {} diff --git a/embassy-executor/tests/ui/spawn_nonsend.stderr b/embassy-executor/tests/ui/spawn_nonsend.stderr index 2a06c8b94..25bd7d78d 100644 --- a/embassy-executor/tests/ui/spawn_nonsend.stderr +++ b/embassy-executor/tests/ui/spawn_nonsend.stderr @@ -12,8 +12,8 @@ error[E0277]: `*mut ()` cannot be sent between threads safely 7 | #[embassy_executor::task] | ------------------------- within this `impl Sized` ... -13 | s.spawn(task(core::ptr::null_mut())).unwrap(); - | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut ()` cannot be sent between threads safely +13 | s.spawn(task(core::ptr::null_mut()).unwrap()); + | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut ()` cannot be sent between threads safely | | | required by a bound introduced by this call | @@ -26,8 +26,8 @@ note: required because it's used within this closure note: required because it appears within the type `impl Sized` --> src/raw/mod.rs | - | pub unsafe fn _spawn_async_fn(&'static self, future: FutFn) -> SpawnToken - | ^^^^^^^^^^ + | pub unsafe fn _spawn_async_fn(&'static self, future: FutFn) -> Result, SpawnError> + | ^^^^^^^^^^ note: required because it appears within the type `impl Sized` --> tests/ui/spawn_nonsend.rs:7:1 | @@ -36,6 +36,6 @@ note: required because it appears within the type `impl Sized` note: required by a bound in `SendSpawner::spawn` --> src/spawner.rs | - | pub fn spawn(&self, token: SpawnToken) -> Result<(), SpawnError> { + | pub fn spawn(&self, token: SpawnToken) { | ^^^^ required by this bound in `SendSpawner::spawn` = note: this error originates in the attribute macro `embassy_executor::task` (in Nightly builds, run with -Z macro-backtrace for more info) -- cgit