Remove unnecessary lets and borrowing from Waker::noop() usage.
`Waker::noop()` now returns a `&'static Waker` reference, so it can be passed directly to `Context` creation with no temporary lifetime issue.
This commit is contained in:
parent
6f8a944ba4
commit
c48cdfe8ee
22 changed files with 24 additions and 46 deletions
|
|
@ -76,8 +76,7 @@ async fn uninhabited_variant() {
|
|||
fn run_fut<T>(fut: impl Future<Output = T>) -> T {
|
||||
use std::task::{Context, Poll, Waker};
|
||||
|
||||
let waker = Waker::noop();
|
||||
let mut context = Context::from_waker(&waker);
|
||||
let mut context = Context::from_waker(Waker::noop());
|
||||
|
||||
let mut pinned = Box::pin(fut);
|
||||
loop {
|
||||
|
|
|
|||
|
|
@ -93,8 +93,7 @@ fn dispatch_on_pin_mut() {
|
|||
let mut fut = async_main();
|
||||
|
||||
// Poll loop, just to test the future...
|
||||
let waker = Waker::noop();
|
||||
let ctx = &mut Context::from_waker(&waker);
|
||||
let ctx = &mut Context::from_waker(Waker::noop());
|
||||
|
||||
loop {
|
||||
match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } {
|
||||
|
|
|
|||
|
|
@ -77,8 +77,7 @@ impl Future for DoStuff {
|
|||
}
|
||||
|
||||
fn run_fut<T>(fut: impl Future<Output = T>) -> T {
|
||||
let waker = Waker::noop();
|
||||
let mut context = Context::from_waker(&waker);
|
||||
let mut context = Context::from_waker(Waker::noop());
|
||||
|
||||
let mut pinned = pin!(fut);
|
||||
loop {
|
||||
|
|
@ -90,8 +89,7 @@ fn run_fut<T>(fut: impl Future<Output = T>) -> T {
|
|||
}
|
||||
|
||||
fn self_referential_box() {
|
||||
let waker = Waker::noop();
|
||||
let cx = &mut Context::from_waker(&waker);
|
||||
let cx = &mut Context::from_waker(Waker::noop());
|
||||
|
||||
async fn my_fut() -> i32 {
|
||||
let val = 10;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ 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 = Waker::noop();
|
||||
let mut context = Context::from_waker(&waker);
|
||||
let mut context = Context::from_waker(Waker::noop());
|
||||
loop {
|
||||
match fut.as_mut().poll(&mut context) {
|
||||
Poll::Ready(v) => return v,
|
||||
|
|
|
|||
|
|
@ -56,8 +56,7 @@ fn data_moved() {
|
|||
fn run_fut<T>(fut: impl Future<Output = T>) -> T {
|
||||
use std::task::{Context, Poll, Waker};
|
||||
|
||||
let waker = Waker::noop();
|
||||
let mut context = Context::from_waker(&waker);
|
||||
let mut context = Context::from_waker(Waker::noop());
|
||||
|
||||
let mut pinned = Box::pin(fut);
|
||||
loop {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue