diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-04-24 03:06:29 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-04-24 04:24:08 +0200 |
| commit | 408617266e21cf3d6ed0e0a5fad435a9ab6140b5 (patch) | |
| tree | a8cf91eff6bb5c4cf4ecda59e3c4f0388b530064 | |
| parent | 11143a1be1243de298d7363ba9a125e3b3e2e068 (diff) | |
Update Rust nightly.
Fixes a new opaque type error in the task macro.
Full error is "opaque type's hidden type cannot be another opaque type from the same scope".
This got disallwed by the lazy-TAIT PR: https://github.com/rust-lang/rust/pull/94081
Sadly there's now some weird type inference errors with pre-lazy-TAIT
nightlies, so support for those is dropped.
| -rw-r--r-- | embassy-macros/src/macros/task.rs | 30 | ||||
| -rw-r--r-- | rust-toolchain.toml | 2 |
2 files changed, 23 insertions, 9 deletions
diff --git a/embassy-macros/src/macros/task.rs b/embassy-macros/src/macros/task.rs index f0c78c596..0cf6b423b 100644 --- a/embassy-macros/src/macros/task.rs +++ b/embassy-macros/src/macros/task.rs | |||
| @@ -61,10 +61,14 @@ pub fn run(args: syn::AttributeArgs, mut f: syn::ItemFn) -> Result<TokenStream, | |||
| 61 | 61 | ||
| 62 | ctxt.check()?; | 62 | ctxt.check()?; |
| 63 | 63 | ||
| 64 | let name = f.sig.ident.clone(); | 64 | let task_ident = f.sig.ident.clone(); |
| 65 | let task_inner_ident = format_ident!("__{}_task", task_ident); | ||
| 66 | let future_ident = format_ident!("__{}_Future", task_ident); | ||
| 67 | let pool_ident = format_ident!("__{}_POOL", task_ident); | ||
| 68 | let new_ts_ident = format_ident!("__{}_NEW_TASKSTORAGE", task_ident); | ||
| 65 | 69 | ||
| 66 | let visibility = &f.vis; | 70 | let visibility = &f.vis; |
| 67 | f.sig.ident = format_ident!("task"); | 71 | f.sig.ident = task_inner_ident.clone(); |
| 68 | let impl_ty = if args.send { | 72 | let impl_ty = if args.send { |
| 69 | quote!(impl ::core::future::Future + Send + 'static) | 73 | quote!(impl ::core::future::Future + Send + 'static) |
| 70 | } else { | 74 | } else { |
| @@ -73,16 +77,26 @@ pub fn run(args: syn::AttributeArgs, mut f: syn::ItemFn) -> Result<TokenStream, | |||
| 73 | 77 | ||
| 74 | let attrs = &f.attrs; | 78 | let attrs = &f.attrs; |
| 75 | 79 | ||
| 80 | let spawn_token = quote!(#embassy_path::executor::SpawnToken); | ||
| 81 | let task_storage = quote!(#embassy_path::executor::raw::TaskStorage); | ||
| 82 | |||
| 76 | let result = quote! { | 83 | let result = quote! { |
| 84 | |||
| 85 | #[allow(non_camel_case_types)] | ||
| 86 | type #future_ident = #impl_ty; | ||
| 87 | |||
| 77 | #(#attrs)* | 88 | #(#attrs)* |
| 78 | #visibility fn #name(#fargs) -> #embassy_path::executor::SpawnToken<#impl_ty> { | 89 | #visibility fn #task_ident(#fargs) -> #spawn_token<#future_ident> { |
| 79 | use #embassy_path::executor::raw::TaskStorage; | ||
| 80 | #f | 90 | #f |
| 81 | type F = #impl_ty; | 91 | |
| 92 | #[allow(non_upper_case_globals)] | ||
| 82 | #[allow(clippy::declare_interior_mutable_const)] | 93 | #[allow(clippy::declare_interior_mutable_const)] |
| 83 | const NEW_TASK: TaskStorage<F> = TaskStorage::new(); | 94 | const #new_ts_ident: #task_storage<#future_ident> = #task_storage::new(); |
| 84 | static POOL: [TaskStorage<F>; #pool_size] = [NEW_TASK; #pool_size]; | 95 | |
| 85 | unsafe { TaskStorage::spawn_pool(&POOL, move || task(#arg_names)) } | 96 | #[allow(non_upper_case_globals)] |
| 97 | static #pool_ident: [#task_storage<#future_ident>; #pool_size] = [#new_ts_ident; #pool_size]; | ||
| 98 | |||
| 99 | unsafe { #task_storage::spawn_pool(&#pool_ident, move || #task_inner_ident(#arg_names)) } | ||
| 86 | } | 100 | } |
| 87 | }; | 101 | }; |
| 88 | 102 | ||
diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 72a832460..e73ef7e90 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # Before upgrading check that everything is available on all tier1 targets here: | 1 | # Before upgrading check that everything is available on all tier1 targets here: |
| 2 | # https://rust-lang.github.io/rustup-components-history | 2 | # https://rust-lang.github.io/rustup-components-history |
| 3 | [toolchain] | 3 | [toolchain] |
| 4 | channel = "nightly-2022-03-10" | 4 | channel = "nightly-2022-04-24" |
| 5 | components = [ "rust-src", "rustfmt" ] | 5 | components = [ "rust-src", "rustfmt" ] |
| 6 | targets = [ "thumbv7em-none-eabi", "thumbv7m-none-eabi", "thumbv6m-none-eabi", "thumbv7em-none-eabihf", "thumbv8m.main-none-eabihf", "wasm32-unknown-unknown" ] | 6 | targets = [ "thumbv7em-none-eabi", "thumbv7m-none-eabi", "thumbv6m-none-eabi", "thumbv7em-none-eabihf", "thumbv8m.main-none-eabihf", "wasm32-unknown-unknown" ] |
