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.
This commit is contained in:
Dario Nieuwenhuis 2022-04-24 03:06:29 +02:00
parent 11143a1be1
commit 408617266e
2 changed files with 23 additions and 9 deletions

View File

@ -61,10 +61,14 @@ pub fn run(args: syn::AttributeArgs, mut f: syn::ItemFn) -> Result<TokenStream,
ctxt.check()?; ctxt.check()?;
let name = f.sig.ident.clone(); let task_ident = f.sig.ident.clone();
let task_inner_ident = format_ident!("__{}_task", task_ident);
let future_ident = format_ident!("__{}_Future", task_ident);
let pool_ident = format_ident!("__{}_POOL", task_ident);
let new_ts_ident = format_ident!("__{}_NEW_TASKSTORAGE", task_ident);
let visibility = &f.vis; let visibility = &f.vis;
f.sig.ident = format_ident!("task"); f.sig.ident = task_inner_ident.clone();
let impl_ty = if args.send { let impl_ty = if args.send {
quote!(impl ::core::future::Future + Send + 'static) quote!(impl ::core::future::Future + Send + 'static)
} else { } else {
@ -73,16 +77,26 @@ pub fn run(args: syn::AttributeArgs, mut f: syn::ItemFn) -> Result<TokenStream,
let attrs = &f.attrs; let attrs = &f.attrs;
let spawn_token = quote!(#embassy_path::executor::SpawnToken);
let task_storage = quote!(#embassy_path::executor::raw::TaskStorage);
let result = quote! { let result = quote! {
#[allow(non_camel_case_types)]
type #future_ident = #impl_ty;
#(#attrs)* #(#attrs)*
#visibility fn #name(#fargs) -> #embassy_path::executor::SpawnToken<#impl_ty> { #visibility fn #task_ident(#fargs) -> #spawn_token<#future_ident> {
use #embassy_path::executor::raw::TaskStorage;
#f #f
type F = #impl_ty;
#[allow(non_upper_case_globals)]
#[allow(clippy::declare_interior_mutable_const)] #[allow(clippy::declare_interior_mutable_const)]
const NEW_TASK: TaskStorage<F> = TaskStorage::new(); const #new_ts_ident: #task_storage<#future_ident> = #task_storage::new();
static POOL: [TaskStorage<F>; #pool_size] = [NEW_TASK; #pool_size];
unsafe { TaskStorage::spawn_pool(&POOL, move || task(#arg_names)) } #[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)) }
} }
}; };

View File

@ -1,6 +1,6 @@
# Before upgrading check that everything is available on all tier1 targets here: # Before upgrading check that everything is available on all tier1 targets here:
# https://rust-lang.github.io/rustup-components-history # https://rust-lang.github.io/rustup-components-history
[toolchain] [toolchain]
channel = "nightly-2022-03-10" channel = "nightly-2022-04-24"
components = [ "rust-src", "rustfmt" ] components = [ "rust-src", "rustfmt" ]
targets = [ "thumbv7em-none-eabi", "thumbv7m-none-eabi", "thumbv6m-none-eabi", "thumbv7em-none-eabihf", "thumbv8m.main-none-eabihf", "wasm32-unknown-unknown" ] targets = [ "thumbv7em-none-eabi", "thumbv7m-none-eabi", "thumbv6m-none-eabi", "thumbv7em-none-eabihf", "thumbv8m.main-none-eabihf", "wasm32-unknown-unknown" ]