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-macros | |
| parent | 34ff67cdbf25e278ff99bd4a05b6b8c6a30fa5d1 (diff) | |
executor: return error when creating the spawntoken, not when spawning.
Diffstat (limited to 'embassy-executor-macros')
| -rw-r--r-- | embassy-executor-macros/src/macros/main.rs | 4 | ||||
| -rw-r--r-- | embassy-executor-macros/src/macros/task.rs | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/embassy-executor-macros/src/macros/main.rs b/embassy-executor-macros/src/macros/main.rs index a0e7b3401..fcc04d9c0 100644 --- a/embassy-executor-macros/src/macros/main.rs +++ b/embassy-executor-macros/src/macros/main.rs | |||
| @@ -181,7 +181,7 @@ For example: `#[embassy_executor::main(entry = ..., executor = \"some_crate::Exe | |||
| 181 | let mut executor = #executor::new(); | 181 | let mut executor = #executor::new(); |
| 182 | let executor = unsafe { __make_static(&mut executor) }; | 182 | let executor = unsafe { __make_static(&mut executor) }; |
| 183 | executor.run(|spawner| { | 183 | executor.run(|spawner| { |
| 184 | spawner.must_spawn(__embassy_main(spawner)); | 184 | spawner.spawn(__embassy_main(spawner).unwrap()); |
| 185 | }) | 185 | }) |
| 186 | }, | 186 | }, |
| 187 | ), | 187 | ), |
| @@ -191,7 +191,7 @@ For example: `#[embassy_executor::main(entry = ..., executor = \"some_crate::Exe | |||
| 191 | let executor = ::std::boxed::Box::leak(::std::boxed::Box::new(#executor::new())); | 191 | let executor = ::std::boxed::Box::leak(::std::boxed::Box::new(#executor::new())); |
| 192 | 192 | ||
| 193 | executor.start(|spawner| { | 193 | executor.start(|spawner| { |
| 194 | spawner.must_spawn(__embassy_main(spawner)); | 194 | spawner.spawn(__embassy_main(spawner).unwrap()); |
| 195 | }); | 195 | }); |
| 196 | 196 | ||
| 197 | Ok(()) | 197 | Ok(()) |
diff --git a/embassy-executor-macros/src/macros/task.rs b/embassy-executor-macros/src/macros/task.rs index fc8673743..755948882 100644 --- a/embassy-executor-macros/src/macros/task.rs +++ b/embassy-executor-macros/src/macros/task.rs | |||
| @@ -234,7 +234,7 @@ pub fn run(args: TokenStream, item: TokenStream) -> TokenStream { | |||
| 234 | if !errors.is_empty() { | 234 | if !errors.is_empty() { |
| 235 | task_outer_body = quote! { | 235 | task_outer_body = quote! { |
| 236 | #![allow(unused_variables, unreachable_code)] | 236 | #![allow(unused_variables, unreachable_code)] |
| 237 | let _x: #embassy_executor::SpawnToken<()> = ::core::todo!(); | 237 | let _x: ::core::result::Result<#embassy_executor::SpawnToken<()>, #embassy_executor::SpawnError> = ::core::todo!(); |
| 238 | _x | 238 | _x |
| 239 | }; | 239 | }; |
| 240 | } | 240 | } |
| @@ -248,7 +248,7 @@ pub fn run(args: TokenStream, item: TokenStream) -> TokenStream { | |||
| 248 | #task_inner | 248 | #task_inner |
| 249 | 249 | ||
| 250 | #(#task_outer_attrs)* | 250 | #(#task_outer_attrs)* |
| 251 | #visibility #unsafety fn #task_ident #generics (#fargs) -> #embassy_executor::SpawnToken<impl Sized> #where_clause{ | 251 | #visibility #unsafety fn #task_ident #generics (#fargs) -> ::core::result::Result<#embassy_executor::SpawnToken<impl Sized>, #embassy_executor::SpawnError> #where_clause{ |
| 252 | #task_outer_body | 252 | #task_outer_body |
| 253 | } | 253 | } |
| 254 | 254 | ||
