diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-07-09 01:49:31 +0200 |
|---|---|---|
| committer | diondokter <[email protected]> | 2025-08-29 13:23:21 +0200 |
| commit | 8aec341f28a00012e1771d5c35d2647e11830755 (patch) | |
| tree | 28ec3bad05e5dcb6ec949493688111839bb6865b /embassy-executor/tests/ui | |
| parent | 34ff67cdbf25e278ff99bd4a05b6b8c6a30fa5d1 (diff) | |
executor: return error when creating the spawntoken, not when spawning.
Diffstat (limited to 'embassy-executor/tests/ui')
5 files changed, 11 insertions, 11 deletions
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<Output = ()> { | |||
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | fn send_spawn(s: SendSpawner) { | 17 | fn send_spawn(s: SendSpawner) { |
| 18 | s.spawn(task()).unwrap(); | 18 | s.spawn(task().unwrap()); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | fn main() {} | 21 | 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 @@ | |||
| 1 | error: future cannot be sent between threads safely | 1 | error: future cannot be sent between threads safely |
| 2 | --> tests/ui/return_impl_future_nonsend.rs:18:13 | 2 | --> tests/ui/return_impl_future_nonsend.rs:18:13 |
| 3 | | | 3 | | |
| 4 | 18 | s.spawn(task()).unwrap(); | 4 | 18 | s.spawn(task().unwrap()); |
| 5 | | ^^^^^^ future created by async block is not `Send` | 5 | | ^^^^^^^^^^^^^^^ future created by async block is not `Send` |
| 6 | | | 6 | | |
| 7 | = help: within `impl Sized`, the trait `Send` is not implemented for `*mut ()` | 7 | = help: within `impl Sized`, the trait `Send` is not implemented for `*mut ()` |
| 8 | note: captured value is not `Send` | 8 | note: captured value is not `Send` |
| @@ -13,5 +13,5 @@ note: captured value is not `Send` | |||
| 13 | note: required by a bound in `SendSpawner::spawn` | 13 | note: required by a bound in `SendSpawner::spawn` |
| 14 | --> src/spawner.rs | 14 | --> src/spawner.rs |
| 15 | | | 15 | | |
| 16 | | pub fn spawn<S: Send>(&self, token: SpawnToken<S>) -> Result<(), SpawnError> { | 16 | | pub fn spawn<S: Send>(&self, token: SpawnToken<S>) { |
| 17 | | ^^^^ required by this bound in `SendSpawner::spawn` | 17 | | ^^^^ 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::<F, N>::spawn` | |||
| 97 | | impl<F: Future + 'static, const N: usize> TaskPool<F, N> { | 97 | | impl<F: Future + 'static, const N: usize> TaskPool<F, N> { |
| 98 | | ^^^^^^ required by this bound in `TaskPool::<F, N>::spawn` | 98 | | ^^^^^^ required by this bound in `TaskPool::<F, N>::spawn` |
| 99 | ... | 99 | ... |
| 100 | | pub fn spawn(&'static self, future: impl FnOnce() -> F) -> SpawnToken<impl Sized> { | 100 | | pub fn spawn(&'static self, future: impl FnOnce() -> F) -> Result<SpawnToken<impl Sized>, SpawnError> { |
| 101 | | ----- required by a bound in this associated function | 101 | | ----- required by a bound in this associated function |
| 102 | = note: this error originates in the attribute macro `embassy_executor::task` (in Nightly builds, run with -Z macro-backtrace for more info) | 102 | = note: this error originates in the attribute macro `embassy_executor::task` (in Nightly builds, run with -Z macro-backtrace for more info) |
| 103 | 103 | ||
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 ()) { | |||
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | fn send_spawn(s: SendSpawner) { | 12 | fn send_spawn(s: SendSpawner) { |
| 13 | s.spawn(task(core::ptr::null_mut())).unwrap(); | 13 | s.spawn(task(core::ptr::null_mut()).unwrap()); |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | fn main() {} | 16 | 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 | |||
| 12 | 7 | #[embassy_executor::task] | 12 | 7 | #[embassy_executor::task] |
| 13 | | ------------------------- within this `impl Sized` | 13 | | ------------------------- within this `impl Sized` |
| 14 | ... | 14 | ... |
| 15 | 13 | s.spawn(task(core::ptr::null_mut())).unwrap(); | 15 | 13 | s.spawn(task(core::ptr::null_mut()).unwrap()); |
| 16 | | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut ()` cannot be sent between threads safely | 16 | | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut ()` cannot be sent between threads safely |
| 17 | | | | 17 | | | |
| 18 | | required by a bound introduced by this call | 18 | | required by a bound introduced by this call |
| 19 | | | 19 | | |
| @@ -26,8 +26,8 @@ note: required because it's used within this closure | |||
| 26 | note: required because it appears within the type `impl Sized` | 26 | note: required because it appears within the type `impl Sized` |
| 27 | --> src/raw/mod.rs | 27 | --> src/raw/mod.rs |
| 28 | | | 28 | | |
| 29 | | pub unsafe fn _spawn_async_fn<FutFn>(&'static self, future: FutFn) -> SpawnToken<impl Sized> | 29 | | pub unsafe fn _spawn_async_fn<FutFn>(&'static self, future: FutFn) -> Result<SpawnToken<impl Sized>, SpawnError> |
| 30 | | ^^^^^^^^^^ | 30 | | ^^^^^^^^^^ |
| 31 | note: required because it appears within the type `impl Sized` | 31 | note: required because it appears within the type `impl Sized` |
| 32 | --> tests/ui/spawn_nonsend.rs:7:1 | 32 | --> tests/ui/spawn_nonsend.rs:7:1 |
| 33 | | | 33 | | |
| @@ -36,6 +36,6 @@ note: required because it appears within the type `impl Sized` | |||
| 36 | note: required by a bound in `SendSpawner::spawn` | 36 | note: required by a bound in `SendSpawner::spawn` |
| 37 | --> src/spawner.rs | 37 | --> src/spawner.rs |
| 38 | | | 38 | | |
| 39 | | pub fn spawn<S: Send>(&self, token: SpawnToken<S>) -> Result<(), SpawnError> { | 39 | | pub fn spawn<S: Send>(&self, token: SpawnToken<S>) { |
| 40 | | ^^^^ required by this bound in `SendSpawner::spawn` | 40 | | ^^^^ required by this bound in `SendSpawner::spawn` |
| 41 | = note: this error originates in the attribute macro `embassy_executor::task` (in Nightly builds, run with -Z macro-backtrace for more info) | 41 | = note: this error originates in the attribute macro `embassy_executor::task` (in Nightly builds, run with -Z macro-backtrace for more info) |
