Skip to content

Commit

Permalink
Rollup merge of #62324 - Centril:reduce-await-macro-reliance, r=cramertj
Browse files Browse the repository at this point in the history
Reduce reliance on `await!(...)` macro

Only the last commit is new.

r? @cramertj
  • Loading branch information
Centril authored Jul 4, 2019
2 parents 566909b + 3eef0cb commit a0493aa
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 30 deletions.
16 changes: 8 additions & 8 deletions src/test/run-pass/async-await/async-fn-size.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// edition:2018

#![feature(async_await, await_macro)]
#![feature(async_await)]

#[path = "../auxiliary/arc_wake.rs"]
mod arc_wake;
Expand Down Expand Up @@ -58,31 +58,31 @@ fn wait(fut: impl Future<Output = u8>) -> u8 {
fn base() -> WakeOnceThenComplete { WakeOnceThenComplete(false, 1) }

async fn await1_level1() -> u8 {
await!(base())
base().await
}

async fn await2_level1() -> u8 {
await!(base()) + await!(base())
base().await + base().await
}

async fn await3_level1() -> u8 {
await!(base()) + await!(base()) + await!(base())
base().await + base().await + base().await
}

async fn await3_level2() -> u8 {
await!(await3_level1()) + await!(await3_level1()) + await!(await3_level1())
await3_level1().await + await3_level1().await + await3_level1().await
}

async fn await3_level3() -> u8 {
await!(await3_level2()) + await!(await3_level2()) + await!(await3_level2())
await3_level2().await + await3_level2().await + await3_level2().await
}

async fn await3_level4() -> u8 {
await!(await3_level3()) + await!(await3_level3()) + await!(await3_level3())
await3_level3().await + await3_level3().await + await3_level3().await
}

async fn await3_level5() -> u8 {
await!(await3_level4()) + await!(await3_level4()) + await!(await3_level4())
await3_level4().await + await3_level4().await + await3_level4().await
}

fn main() {
Expand Down
4 changes: 2 additions & 2 deletions src/test/run-pass/async-await/issue-60709.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// handled incorrectly in generators.
// compile-flags: -Copt-level=z -Cdebuginfo=2 --edition=2018

#![feature(async_await, await_macro)]
#![feature(async_await)]
#![allow(unused)]

use std::future::Future;
Expand All @@ -22,7 +22,7 @@ impl Future for Never {
fn main() {
let fut = async {
let _rc = Rc::new(()); // Also crashes with Arc
await!(Never());
Never().await;
};
let _bla = fut; // Moving the future is required.
}
2 changes: 1 addition & 1 deletion src/test/ui/async-await/async-fn-path-elision.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// edition:2018

#![feature(async_await, await_macro)]
#![feature(async_await)]
#![allow(dead_code)]

struct HasLifetime<'a>(&'a bool);
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/async-await/async-with-closure.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// build-pass (FIXME(62277): could be check-pass?)
// edition:2018

#![feature(async_await, await_macro)]
#![feature(async_await)]

trait MyClosure {
type Args;
Expand All @@ -20,7 +20,7 @@ async fn get_future<C: ?Sized + MyClosure>(_stream: MyStream<C>) {}

async fn f() {
let messages: MyStream<dyn FnMut()> = unimplemented!();
await!(get_future(messages));
get_future(messages).await;
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// edition:2018

#![allow(non_camel_case_types)]
#![feature(async_await, await_macro)]
#![feature(async_await)]

mod outer_mod {
pub mod await { //~ ERROR expected identifier, found reserved keyword `await`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// run-pass

#![allow(unused_variables)]
#![feature(async_await, await_macro)]
#![feature(async_await)]

// Test that the drop order for parameters in a fn and async fn matches up. Also test that
// parameters (used or unused) are not dropped until the async fn completes execution.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// run-pass

#![allow(unused_variables)]
#![feature(async_await, await_macro)]
#![feature(async_await)]

// Test that the drop order for parameters in a fn and async fn matches up. Also test that
// parameters (used or unused) are not dropped until the async fn completes execution.
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/async-await/issues/issue-53249.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// build-pass (FIXME(62277): could be check-pass?)
// edition:2018

#![feature(arbitrary_self_types, async_await, await_macro)]
#![feature(arbitrary_self_types, async_await)]

use std::task::{self, Poll};
use std::future::Future;
Expand Down Expand Up @@ -37,11 +37,11 @@ impl<R, F> Future for Lazy<F>
async fn __receive<WantFn, Fut>(want: WantFn) -> ()
where Fut: Future<Output = ()>, WantFn: Fn(&Box<dyn Send + 'static>) -> Fut,
{
await!(lazy(|_| ()));
lazy(|_| ()).await;
}

pub fn basic_spawn_receive() {
async { await!(__receive(|_| async { () })) };
async { __receive(|_| async { () }).await };
}

fn main() {}
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issues/issue-54974.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// build-pass (FIXME(62277): could be check-pass?)
// edition:2018

#![feature(async_await, await_macro)]
#![feature(async_await)]

use std::sync::Arc;

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/async-await/issues/issue-55324.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// build-pass (FIXME(62277): could be check-pass?)
// edition:2018

#![feature(async_await, await_macro)]
#![feature(async_await)]

use std::future::Future;

#[allow(unused)]
async fn foo<F: Future<Output = i32>>(x: &i32, future: F) -> i32 {
let y = await!(future);
let y = future.await;
*x + y
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issues/issue-58885.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// build-pass (FIXME(62277): could be check-pass?)
// edition:2018

#![feature(async_await, await_macro)]
#![feature(async_await)]

struct Xyz {
a: u64,
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issues/issue-59001.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// build-pass (FIXME(62277): could be check-pass?)
// edition:2018

#![feature(async_await, await_macro)]
#![feature(async_await)]

use std::future::Future;

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/async-await/issues/issue-59972.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// compile-flags: --edition=2018

#![feature(async_await, await_macro)]
#![feature(async_await)]

pub enum Uninhabited { }

Expand All @@ -15,7 +15,7 @@ async fn noop() { }
#[allow(unused)]
async fn contains_never() {
let error = uninhabited_async();
await!(noop());
noop().await;
let error2 = error;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/multiple-lifetimes/hrtb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// Test that we can use async fns with multiple arbitrary lifetimes.

#![feature(arbitrary_self_types, async_await, await_macro)]
#![feature(async_await)]
#![allow(dead_code)]

use std::ops::Add;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/no-args-non-move-async-closure.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// edition:2018

#![feature(async_await, async_closure, await_macro)]
#![feature(async_await, async_closure)]

fn main() {
let _ = async |x: u8| {};
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/async-await/recursive-async-impl-trait-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Test that impl trait does not allow creating recursive types that are
// otherwise forbidden when using `async` and `await`.

#![feature(await_macro, async_await, generators)]
#![feature(async_await)]

async fn recursive_async_function() -> () { //~ ERROR
await!(recursive_async_function());
recursive_async_function().await;
}

fn main() {}

0 comments on commit a0493aa

Please sign in to comment.