1
Fork 0

coverage: Use Waker::noop in async tests

This commit is contained in:
Zalathar 2023-12-15 16:38:27 +11:00
parent 604f185fae
commit 5764ccc5e8
9 changed files with 134 additions and 353 deletions

View file

@ -1,5 +1,6 @@
// compile-flags: --edition=2018
#![feature(coverage_attribute)]
#![feature(noop_waker)]
// edition: 2018
macro_rules! bail {
($msg:literal $(,)?) => {
@ -45,27 +46,14 @@ fn main() {
}
mod executor {
use core::{
future::Future,
pin::Pin,
task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
};
use core::future::Future;
use core::pin::pin;
use core::task::{Context, Poll, Waker};
#[coverage(off)]
pub fn block_on<F: Future>(mut future: F) -> F::Output {
let mut future = unsafe { Pin::new_unchecked(&mut future) };
use std::hint::unreachable_unchecked;
static VTABLE: RawWakerVTable = RawWakerVTable::new(
#[coverage(off)]
|_| unsafe { unreachable_unchecked() }, // clone
#[coverage(off)]
|_| unsafe { unreachable_unchecked() }, // wake
#[coverage(off)]
|_| unsafe { unreachable_unchecked() }, // wake_by_ref
#[coverage(off)]
|_| (),
);
let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
let mut future = pin!(future);
let waker = Waker::noop();
let mut context = Context::from_waker(&waker);
loop {