Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
slanterns committed Jul 26, 2024
1 parent 406c483 commit 5c49c17
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/ui/consts/const_waker.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//@ check-pass
#![allow(dead_code)]

use core::{
future::Future,
pin::Pin,
task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
};

const NOP_RAWWAKER: RawWaker = {
fn nop(_: *const ()) {}
const VTAB: RawWakerVTable = RawWakerVTable::new(|_| NOP_RAWWAKER, nop, nop, nop);
RawWaker::new(&() as *const (), &VTAB)
};

const NOP_WAKER: &Waker = &unsafe { Waker::from_raw(NOP_RAWWAKER) };

const NOP_CONTEXT: Context<'static> = Context::from_waker(NOP_WAKER);

fn poll_once<T, F>(f: &mut F) -> Poll<T>
where
F: Future<Output = T> + ?Sized + Unpin,
{
let mut cx = NOP_CONTEXT;
Pin::new(f).as_mut().poll(&mut cx)
}

fn main() {}

0 comments on commit 5c49c17

Please sign in to comment.