Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions tests/pass/async-fn.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(never_type)]
#![feature(noop_waker)]

use std::future::Future;

Expand Down Expand Up @@ -58,17 +59,9 @@ async fn hello_world() {
}

fn run_fut<T>(fut: impl Future<Output = T>) -> T {
use std::sync::Arc;
use std::task::{Context, Poll, Wake, Waker};
use std::task::{Context, Poll, Waker};

struct MyWaker;
impl Wake for MyWaker {
fn wake(self: Arc<Self>) {
unimplemented!()
}
}

let waker = Waker::from(Arc::new(MyWaker));
let waker = Waker::noop();
let mut context = Context::from_waker(&waker);

let mut pinned = Box::pin(fut);
Expand Down
18 changes: 2 additions & 16 deletions tests/pass/dyn-star.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![feature(dyn_star)]
#![allow(incomplete_features)]
#![feature(custom_inner_attributes)]
#![feature(noop_waker)]
// rustfmt destroys `dyn* Trait` syntax
#![rustfmt::skip]

Expand Down Expand Up @@ -89,25 +90,10 @@ fn dispatch_on_pin_mut() {
use std::pin::Pin;
use std::task::*;

pub fn noop_waker() -> Waker {
let raw = RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE);

// SAFETY: the contracts for RawWaker and RawWakerVTable are upheld
unsafe { Waker::from_raw(raw) }
}

const NOOP_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(noop_clone, noop, noop, noop);

unsafe fn noop_clone(_p: *const ()) -> RawWaker {
RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE)
}

unsafe fn noop(_p: *const ()) {}

let mut fut = async_main();

// Poll loop, just to test the future...
let waker = noop_waker();
let waker = Waker::noop();
let ctx = &mut Context::from_waker(&waker);

loop {
Expand Down
18 changes: 3 additions & 15 deletions tests/pass/future-self-referential.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows
#![feature(noop_waker)]

use std::future::*;
use std::marker::PhantomPinned;
Expand Down Expand Up @@ -29,19 +30,6 @@ impl Future for Delay {
}
}

fn mk_waker() -> Waker {
use std::sync::Arc;

struct MyWaker;
impl Wake for MyWaker {
fn wake(self: Arc<Self>) {
unimplemented!()
}
}

Waker::from(Arc::new(MyWaker))
}

async fn do_stuff() {
(&mut Delay::new(1)).await;
}
Expand Down Expand Up @@ -89,7 +77,7 @@ impl Future for DoStuff {
}

fn run_fut<T>(fut: impl Future<Output = T>) -> T {
let waker = mk_waker();
let waker = Waker::noop();
let mut context = Context::from_waker(&waker);

let mut pinned = pin!(fut);
Expand All @@ -102,7 +90,7 @@ fn run_fut<T>(fut: impl Future<Output = T>) -> T {
}

fn self_referential_box() {
let waker = mk_waker();
let waker = Waker::noop();
let cx = &mut Context::from_waker(&waker);

async fn my_fut() -> i32 {
Expand Down
18 changes: 6 additions & 12 deletions tests/pass/issues/issue-miri-2068.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
use core::future::Future;
use core::pin::Pin;
use core::task::{Context, Poll};
#![feature(noop_waker)]

use std::sync::Arc;

struct NopWaker;

impl std::task::Wake for NopWaker {
fn wake(self: Arc<Self>) {}
}
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll, Waker};

pub fn fuzzing_block_on<O, F: Future<Output = O>>(fut: F) -> O {
let mut fut = std::pin::pin!(fut);
let waker = std::task::Waker::from(Arc::new(NopWaker));
let mut context = std::task::Context::from_waker(&waker);
let waker = Waker::noop();
let mut context = Context::from_waker(&waker);
loop {
match fut.as_mut().poll(&mut context) {
Poll::Ready(v) => return v,
Expand Down
13 changes: 3 additions & 10 deletions tests/pass/move-data-across-await-point.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![feature(noop_waker)]
use std::future::Future;
use std::ptr;

Expand Down Expand Up @@ -53,17 +54,9 @@ fn data_moved() {
}

fn run_fut<T>(fut: impl Future<Output = T>) -> T {
use std::sync::Arc;
use std::task::{Context, Poll, Wake, Waker};
use std::task::{Context, Poll, Waker};

struct MyWaker;
impl Wake for MyWaker {
fn wake(self: Arc<Self>) {
unimplemented!()
}
}

let waker = Waker::from(Arc::new(MyWaker));
let waker = Waker::noop();
let mut context = Context::from_waker(&waker);

let mut pinned = Box::pin(fut);
Expand Down