cf6d6050f7
* The WASI targets deal with the `main` symbol a bit differently than native so some `codegen` and `assembly` tests have been ignored. * All `ignore-emscripten` directives have been updated to `ignore-wasm32` to be more clear that all wasm targets are ignored and it's not just Emscripten. * Most `ignore-wasm32-bare` directives are now gone. * Some ignore directives for wasm were switched to `needs-unwind` instead. * Many `ignore-wasm32*` directives are removed as the tests work with WASI as opposed to `wasm32-unknown-unknown`.
46 lines
1.2 KiB
Rust
46 lines
1.2 KiB
Rust
// issue 65419 - Attempting to run an async fn after completion mentions coroutines when it should
|
|
// be talking about `async fn`s instead.
|
|
|
|
//@ run-fail
|
|
//@ error-pattern: thread 'main' panicked
|
|
//@ error-pattern: `async fn` resumed after completion
|
|
//@ edition:2018
|
|
|
|
#![feature(coroutines, coroutine_trait)]
|
|
|
|
async fn foo() {
|
|
}
|
|
|
|
fn main() {
|
|
let mut future = Box::pin(foo());
|
|
executor::block_on(future.as_mut());
|
|
executor::block_on(future.as_mut());
|
|
}
|
|
|
|
mod executor {
|
|
use core::{
|
|
future::Future,
|
|
pin::Pin,
|
|
task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
|
|
};
|
|
|
|
pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
|
let mut future = unsafe { Pin::new_unchecked(&mut future) };
|
|
|
|
static VTABLE: RawWakerVTable = RawWakerVTable::new(
|
|
|_| unimplemented!("clone"),
|
|
|_| unimplemented!("wake"),
|
|
|_| unimplemented!("wake_by_ref"),
|
|
|_| (),
|
|
);
|
|
let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
|
|
let mut context = Context::from_waker(&waker);
|
|
|
|
loop {
|
|
if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
|
break val;
|
|
}
|
|
}
|
|
}
|
|
}
|