Remove unnecessary let
s 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
|
@ -7,8 +7,7 @@ fn into_async_iter() {
|
||||||
let async_iter = async_iter::from_iter(0..3);
|
let async_iter = async_iter::from_iter(0..3);
|
||||||
let mut async_iter = pin!(async_iter.into_async_iter());
|
let mut async_iter = pin!(async_iter.into_async_iter());
|
||||||
|
|
||||||
let waker = core::task::Waker::noop();
|
let mut cx = &mut core::task::Context::from_waker(core::task::Waker::noop());
|
||||||
let mut cx = &mut core::task::Context::from_waker(&waker);
|
|
||||||
|
|
||||||
assert_eq!(async_iter.as_mut().poll_next(&mut cx), Poll::Ready(Some(0)));
|
assert_eq!(async_iter.as_mut().poll_next(&mut cx), Poll::Ready(Some(0)));
|
||||||
assert_eq!(async_iter.as_mut().poll_next(&mut cx), Poll::Ready(Some(1)));
|
assert_eq!(async_iter.as_mut().poll_next(&mut cx), Poll::Ready(Some(1)));
|
||||||
|
|
|
@ -76,8 +76,7 @@ async fn uninhabited_variant() {
|
||||||
fn run_fut<T>(fut: impl Future<Output = T>) -> T {
|
fn run_fut<T>(fut: impl Future<Output = T>) -> T {
|
||||||
use std::task::{Context, Poll, Waker};
|
use std::task::{Context, Poll, Waker};
|
||||||
|
|
||||||
let waker = Waker::noop();
|
let mut context = Context::from_waker(Waker::noop());
|
||||||
let mut context = Context::from_waker(&waker);
|
|
||||||
|
|
||||||
let mut pinned = Box::pin(fut);
|
let mut pinned = Box::pin(fut);
|
||||||
loop {
|
loop {
|
||||||
|
|
|
@ -93,8 +93,7 @@ fn dispatch_on_pin_mut() {
|
||||||
let mut fut = async_main();
|
let mut fut = async_main();
|
||||||
|
|
||||||
// Poll loop, just to test the future...
|
// Poll loop, just to test the future...
|
||||||
let waker = Waker::noop();
|
let ctx = &mut Context::from_waker(Waker::noop());
|
||||||
let ctx = &mut Context::from_waker(&waker);
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } {
|
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 {
|
fn run_fut<T>(fut: impl Future<Output = T>) -> T {
|
||||||
let waker = Waker::noop();
|
let mut context = Context::from_waker(Waker::noop());
|
||||||
let mut context = Context::from_waker(&waker);
|
|
||||||
|
|
||||||
let mut pinned = pin!(fut);
|
let mut pinned = pin!(fut);
|
||||||
loop {
|
loop {
|
||||||
|
@ -90,8 +89,7 @@ fn run_fut<T>(fut: impl Future<Output = T>) -> T {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn self_referential_box() {
|
fn self_referential_box() {
|
||||||
let waker = Waker::noop();
|
let cx = &mut Context::from_waker(Waker::noop());
|
||||||
let cx = &mut Context::from_waker(&waker);
|
|
||||||
|
|
||||||
async fn my_fut() -> i32 {
|
async fn my_fut() -> i32 {
|
||||||
let val = 10;
|
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 {
|
pub fn fuzzing_block_on<O, F: Future<Output = O>>(fut: F) -> O {
|
||||||
let mut fut = std::pin::pin!(fut);
|
let mut fut = std::pin::pin!(fut);
|
||||||
let waker = Waker::noop();
|
let mut context = Context::from_waker(Waker::noop());
|
||||||
let mut context = Context::from_waker(&waker);
|
|
||||||
loop {
|
loop {
|
||||||
match fut.as_mut().poll(&mut context) {
|
match fut.as_mut().poll(&mut context) {
|
||||||
Poll::Ready(v) => return v,
|
Poll::Ready(v) => return v,
|
||||||
|
|
|
@ -56,8 +56,7 @@ fn data_moved() {
|
||||||
fn run_fut<T>(fut: impl Future<Output = T>) -> T {
|
fn run_fut<T>(fut: impl Future<Output = T>) -> T {
|
||||||
use std::task::{Context, Poll, Waker};
|
use std::task::{Context, Poll, Waker};
|
||||||
|
|
||||||
let waker = Waker::noop();
|
let mut context = Context::from_waker(Waker::noop());
|
||||||
let mut context = Context::from_waker(&waker);
|
|
||||||
|
|
||||||
let mut pinned = Box::pin(fut);
|
let mut pinned = Box::pin(fut);
|
||||||
loop {
|
loop {
|
||||||
|
|
|
@ -117,8 +117,7 @@
|
||||||
LL| | #[coverage(off)]
|
LL| | #[coverage(off)]
|
||||||
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
||||||
LL| | let mut future = pin!(future);
|
LL| | let mut future = pin!(future);
|
||||||
LL| | let waker = Waker::noop();
|
LL| | let mut context = Context::from_waker(Waker::noop());
|
||||||
LL| | let mut context = Context::from_waker(&waker);
|
|
||||||
LL| |
|
LL| |
|
||||||
LL| | loop {
|
LL| | loop {
|
||||||
LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
||||||
|
|
|
@ -110,8 +110,7 @@ mod executor {
|
||||||
#[coverage(off)]
|
#[coverage(off)]
|
||||||
pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
||||||
let mut future = pin!(future);
|
let mut future = pin!(future);
|
||||||
let waker = Waker::noop();
|
let mut context = Context::from_waker(Waker::noop());
|
||||||
let mut context = Context::from_waker(&waker);
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
||||||
|
|
|
@ -41,8 +41,7 @@
|
||||||
LL| | #[coverage(off)]
|
LL| | #[coverage(off)]
|
||||||
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
||||||
LL| | let mut future = pin!(future);
|
LL| | let mut future = pin!(future);
|
||||||
LL| | let waker = Waker::noop();
|
LL| | let mut context = Context::from_waker(Waker::noop());
|
||||||
LL| | let mut context = Context::from_waker(&waker);
|
|
||||||
LL| |
|
LL| |
|
||||||
LL| | loop {
|
LL| | loop {
|
||||||
LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
||||||
|
|
|
@ -39,8 +39,7 @@ mod executor {
|
||||||
#[coverage(off)]
|
#[coverage(off)]
|
||||||
pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
||||||
let mut future = pin!(future);
|
let mut future = pin!(future);
|
||||||
let waker = Waker::noop();
|
let mut context = Context::from_waker(Waker::noop());
|
||||||
let mut context = Context::from_waker(&waker);
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
||||||
|
|
|
@ -24,8 +24,7 @@
|
||||||
LL| | #[coverage(off)]
|
LL| | #[coverage(off)]
|
||||||
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
||||||
LL| | let mut future = pin!(future);
|
LL| | let mut future = pin!(future);
|
||||||
LL| | let waker = Waker::noop();
|
LL| | let mut context = Context::from_waker(Waker::noop());
|
||||||
LL| | let mut context = Context::from_waker(&waker);
|
|
||||||
LL| |
|
LL| |
|
||||||
LL| | loop {
|
LL| | loop {
|
||||||
LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
||||||
|
|
|
@ -23,8 +23,7 @@ mod executor {
|
||||||
#[coverage(off)]
|
#[coverage(off)]
|
||||||
pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
||||||
let mut future = pin!(future);
|
let mut future = pin!(future);
|
||||||
let waker = Waker::noop();
|
let mut context = Context::from_waker(Waker::noop());
|
||||||
let mut context = Context::from_waker(&waker);
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
||||||
|
|
|
@ -54,8 +54,7 @@
|
||||||
LL| | #[coverage(off)]
|
LL| | #[coverage(off)]
|
||||||
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
||||||
LL| | let mut future = pin!(future);
|
LL| | let mut future = pin!(future);
|
||||||
LL| | let waker = Waker::noop();
|
LL| | let mut context = Context::from_waker(Waker::noop());
|
||||||
LL| | let mut context = Context::from_waker(&waker);
|
|
||||||
LL| |
|
LL| |
|
||||||
LL| | loop {
|
LL| | loop {
|
||||||
LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
||||||
|
|
|
@ -53,8 +53,7 @@ mod executor {
|
||||||
#[coverage(off)]
|
#[coverage(off)]
|
||||||
pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
||||||
let mut future = pin!(future);
|
let mut future = pin!(future);
|
||||||
let waker = Waker::noop();
|
let mut context = Context::from_waker(Waker::noop());
|
||||||
let mut context = Context::from_waker(&waker);
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
|
||||||
|
|
|
@ -25,8 +25,7 @@ async fn real_main() {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let future = real_main();
|
let future = real_main();
|
||||||
let waker = std::task::Waker::noop();
|
let mut cx = &mut core::task::Context::from_waker(std::task::Waker::noop());
|
||||||
let mut cx = &mut core::task::Context::from_waker(&waker);
|
|
||||||
let mut future = core::pin::pin!(future);
|
let mut future = core::pin::pin!(future);
|
||||||
while let core::task::Poll::Pending = future.as_mut().poll(&mut cx) {}
|
while let core::task::Poll::Pending = future.as_mut().poll(&mut cx) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,7 @@ async fn real_main() {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let future = real_main();
|
let future = real_main();
|
||||||
let waker = std::task::Waker::noop();
|
let mut cx = &mut core::task::Context::from_waker(std::task::Waker::noop());
|
||||||
let mut cx = &mut core::task::Context::from_waker(&waker);
|
|
||||||
let mut future = core::pin::pin!(future);
|
let mut future = core::pin::pin!(future);
|
||||||
while let core::task::Poll::Pending = future.as_mut().poll(&mut cx) {}
|
while let core::task::Poll::Pending = future.as_mut().poll(&mut cx) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,7 @@ fn main() {
|
||||||
let mut fut = pin!(async_main());
|
let mut fut = pin!(async_main());
|
||||||
|
|
||||||
// Poll loop, just to test the future...
|
// Poll loop, just to test the future...
|
||||||
let waker = Waker::noop();
|
let ctx = &mut Context::from_waker(Waker::noop());
|
||||||
let ctx = &mut Context::from_waker(&waker);
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match fut.as_mut().poll(ctx) {
|
match fut.as_mut().poll(ctx) {
|
||||||
|
|
|
@ -43,8 +43,7 @@ fn main() {
|
||||||
let mut fut = pin!(async_main());
|
let mut fut = pin!(async_main());
|
||||||
|
|
||||||
// Poll loop, just to test the future...
|
// Poll loop, just to test the future...
|
||||||
let waker = Waker::noop();
|
let ctx = &mut Context::from_waker(Waker::noop());
|
||||||
let ctx = &mut Context::from_waker(&waker);
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match fut.as_mut().poll(ctx) {
|
match fut.as_mut().poll(ctx) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ LL | default async fn foo(_: T) -> &'static str {
|
||||||
= note: specialization behaves in inconsistent and surprising ways with async functions in traits, and for now is disallowed
|
= note: specialization behaves in inconsistent and surprising ways with async functions in traits, and for now is disallowed
|
||||||
|
|
||||||
error[E0599]: no method named `poll` found for struct `Pin<&mut impl Future<Output = ()>>` in the current scope
|
error[E0599]: no method named `poll` found for struct `Pin<&mut impl Future<Output = ()>>` in the current scope
|
||||||
--> $DIR/dont-project-to-specializable-projection.rs:50:28
|
--> $DIR/dont-project-to-specializable-projection.rs:49:28
|
||||||
|
|
|
|
||||||
LL | match fut.as_mut().poll(ctx) {
|
LL | match fut.as_mut().poll(ctx) {
|
||||||
| ^^^^ method not found in `Pin<&mut impl Future<Output = ()>>`
|
| ^^^^ method not found in `Pin<&mut impl Future<Output = ()>>`
|
||||||
|
|
|
@ -11,7 +11,6 @@ async gen fn gen_fn() -> &'static str {
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let async_iterator = pin!(gen_fn());
|
let async_iterator = pin!(gen_fn());
|
||||||
let waker = Waker::noop();
|
let ctx = &mut Context::from_waker(Waker::noop());
|
||||||
let ctx = &mut Context::from_waker(&waker);
|
|
||||||
async_iterator.poll_next(ctx);
|
async_iterator.poll_next(ctx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,7 @@ fn main() {
|
||||||
let mut fut = pin!(async_main());
|
let mut fut = pin!(async_main());
|
||||||
|
|
||||||
// Poll loop, just to test the future...
|
// Poll loop, just to test the future...
|
||||||
let waker = Waker::noop();
|
let ctx = &mut Context::from_waker(Waker::noop());
|
||||||
let ctx = &mut Context::from_waker(&waker);
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match fut.as_mut().poll(ctx) {
|
match fut.as_mut().poll(ctx) {
|
||||||
|
|
|
@ -19,15 +19,14 @@ async fn async_main() {
|
||||||
// ------------------------------------------------------------------------- //
|
// ------------------------------------------------------------------------- //
|
||||||
// Implementation Details Below...
|
// Implementation Details Below...
|
||||||
|
|
||||||
use std::task::*;
|
|
||||||
use std::pin::pin;
|
use std::pin::pin;
|
||||||
|
use std::task::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut fut = pin!(async_main());
|
let mut fut = pin!(async_main());
|
||||||
|
|
||||||
// Poll loop, just to test the future...
|
// Poll loop, just to test the future...
|
||||||
let waker = Waker::noop();
|
let ctx = &mut Context::from_waker(Waker::noop());
|
||||||
let ctx = &mut Context::from_waker(&waker);
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match fut.as_mut().poll(ctx) {
|
match fut.as_mut().poll(ctx) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue