From 408617266e21cf3d6ed0e0a5fad435a9ab6140b5 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sun, 24 Apr 2022 03:06:29 +0200 Subject: [PATCH] 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. --- embassy-macros/src/macros/task.rs | 30 ++++++++++++++++++++++-------- 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 f0c78c59..0cf6b423 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 Result #embassy_path::executor::SpawnToken<#impl_ty> { - use #embassy_path::executor::raw::TaskStorage; + #visibility fn #task_ident(#fargs) -> #spawn_token<#future_ident> { #f - type F = #impl_ty; + + #[allow(non_upper_case_globals)] #[allow(clippy::declare_interior_mutable_const)] - const NEW_TASK: TaskStorage = TaskStorage::new(); - static POOL: [TaskStorage; #pool_size] = [NEW_TASK; #pool_size]; - unsafe { TaskStorage::spawn_pool(&POOL, move || task(#arg_names)) } + const #new_ts_ident: #task_storage<#future_ident> = #task_storage::new(); + + #[allow(non_upper_case_globals)] + static #pool_ident: [#task_storage<#future_ident>; #pool_size] = [#new_ts_ident; #pool_size]; + + unsafe { #task_storage::spawn_pool(&#pool_ident, move || #task_inner_ident(#arg_names)) } } }; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 72a83246..e73ef7e9 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,6 +1,6 @@ # Before upgrading check that everything is available on all tier1 targets here: # https://rust-lang.github.io/rustup-components-history [toolchain] -channel = "nightly-2022-03-10" +channel = "nightly-2022-04-24" components = [ "rust-src", "rustfmt" ] targets = [ "thumbv7em-none-eabi", "thumbv7m-none-eabi", "thumbv6m-none-eabi", "thumbv7em-none-eabihf", "thumbv8m.main-none-eabihf", "wasm32-unknown-unknown" ]