Skip to content

Commit

Permalink
Fix the nightly futures support
Browse files Browse the repository at this point in the history
Type Alias Impl Trait (TAIT) seems to now require the type to be
declared in a separate module from where it's used. I don't exactly know
the reasoning for this, but it's fixed now regardless.
  • Loading branch information
CryZe committed Aug 14, 2024
1 parent 83f7de0 commit 04ba821
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,25 +345,25 @@ macro_rules! async_main {
#[no_mangle]
pub unsafe extern "C" fn update() {
use core::{
cell::UnsafeCell,
future::Future,
pin::Pin,
ptr,
task::{Context, RawWaker, RawWakerVTable, Waker},
};

type MainFuture = impl Future<Output = ()>;
const fn main_type() -> MainFuture {
async {
main().await;
mod fut {
pub type MainFuture = impl core::future::Future<Output = ()>;
pub const fn main_type() -> MainFuture {
async {
super::main().await;
}
}
}
static mut STATE: MainFuture = main_type();
static mut STATE: UnsafeCell<fut::MainFuture> = UnsafeCell::new(fut::main_type());
static mut FINISHED: bool = false;

if unsafe { FINISHED } {
return;
}

static VTABLE: RawWakerVTable = RawWakerVTable::new(
|_| RawWaker::new(ptr::null(), &VTABLE),
|_| {},
Expand All @@ -374,7 +374,7 @@ macro_rules! async_main {
let waker = unsafe { Waker::from_raw(raw_waker) };
let mut cx = Context::from_waker(&waker);
unsafe {
FINISHED = Pin::new_unchecked(&mut STATE).poll(&mut cx).is_ready();
FINISHED = Pin::new_unchecked(STATE.get_mut()).poll(&mut cx).is_ready();
}
}
};
Expand Down

0 comments on commit 04ba821

Please sign in to comment.