Skip to content

Commit fe324c1

Browse files
committed
Replace await! macro with await syntax
1 parent f4dad66 commit fe324c1

36 files changed

+223
-222
lines changed

futures-channel/tests/channel.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(async_await, await_macro)]
1+
#![feature(async_await)]
22

33
use futures::channel::mpsc;
44
use futures::executor::block_on;
@@ -28,7 +28,7 @@ fn sequence() {
2828

2929
async fn send_sequence(n: u32, mut sender: mpsc::Sender<u32>) {
3030
for x in 0..n {
31-
await!(sender.send(n - x)).unwrap();
31+
sender.send(n - x).await.unwrap();
3232
}
3333
}
3434

futures-channel/tests/mpsc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(async_await, await_macro)]
1+
#![feature(async_await)]
22

33
use futures::channel::{mpsc, oneshot};
44
use futures::executor::{block_on, block_on_stream};
@@ -357,7 +357,7 @@ fn stress_drop_sender() {
357357

358358
async fn send_one_two_three(mut tx: mpsc::Sender<i32>) {
359359
for i in 1..=3 {
360-
await!(tx.send(i)).unwrap();
360+
tx.send(i).await.unwrap();
361361
}
362362
}
363363

@@ -403,7 +403,7 @@ fn stress_close_receiver() {
403403

404404
async fn stress_poll_ready_sender(mut sender: mpsc::Sender<u32>, count: u32) {
405405
for i in (1..=count).rev() {
406-
await!(sender.send(i)).unwrap();
406+
sender.send(i).await.unwrap();
407407
}
408408
}
409409

futures-select-macro/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,9 @@ pub fn select(input: TokenStream) -> TokenStream {
246246
};
247247
}
248248
} else {
249+
// TODO: should we use `r#await`?
249250
quote! {
250-
match r#await!(#futures_crate::future::poll_fn(__poll_fn)) {
251+
match #futures_crate::future::poll_fn(__poll_fn).await {
251252
#branches
252253
}
253254
}

futures-util/src/async_await/join.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// Polls multiple futures simultaneously, returning a tuple
44
/// of all results once complete.
55
///
6-
/// While `join!(a, b)` is similar to `(await!(a), await!(b))`,
6+
/// While `join!(a, b)` is similar to `(a.await, b.await)`,
77
/// `join!` polls both futures concurrently and therefore is more efficent.
88
///
99
/// This macro is only usable inside of async functions, closures, and blocks.
@@ -13,7 +13,7 @@
1313
/// # Examples
1414
///
1515
/// ```
16-
/// #![feature(async_await, await_macro)]
16+
/// #![feature(async_await)]
1717
/// # futures::executor::block_on(async {
1818
/// use futures::{join, future};
1919
///
@@ -31,7 +31,7 @@ macro_rules! join {
3131
// is no longer accessible by the end user.
3232
let mut $fut = $crate::future::maybe_done($fut);
3333
)*
34-
await!($crate::future::poll_fn(move |cx| {
34+
$crate::future::poll_fn(move |cx| {
3535
let mut all_done = true;
3636
$(
3737
all_done &= $crate::core_reexport::future::Future::poll(
@@ -44,7 +44,7 @@ macro_rules! join {
4444
} else {
4545
$crate::core_reexport::task::Poll::Pending
4646
}
47-
}))
47+
}).await
4848
} }
4949
}
5050

@@ -64,7 +64,7 @@ macro_rules! join {
6464
/// `Ok` of a tuple of the values:
6565
///
6666
/// ```
67-
/// #![feature(async_await, await_macro)]
67+
/// #![feature(async_await)]
6868
/// # futures::executor::block_on(async {
6969
/// use futures::{try_join, future};
7070
///
@@ -79,7 +79,7 @@ macro_rules! join {
7979
/// that error:
8080
///
8181
/// ```
82-
/// #![feature(async_await, await_macro)]
82+
/// #![feature(async_await)]
8383
/// # futures::executor::block_on(async {
8484
/// use futures::{try_join, future};
8585
///
@@ -98,7 +98,7 @@ macro_rules! try_join {
9898
let mut $fut = $crate::future::maybe_done($fut);
9999
)*
100100

101-
let res: $crate::core_reexport::result::Result<_, _> = await!($crate::future::poll_fn(move |cx| {
101+
let res: $crate::core_reexport::result::Result<_, _> = $crate::future::poll_fn(move |cx| {
102102
let mut all_done = true;
103103
$(
104104
if $crate::core_reexport::future::Future::poll(
@@ -126,7 +126,7 @@ macro_rules! try_join {
126126
} else {
127127
$crate::core_reexport::task::Poll::Pending
128128
}
129-
}));
129+
}).await;
130130

131131
res
132132
} }

futures-util/src/async_await/pending.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use futures_core::task::{Context, Poll};
1515
#[macro_export]
1616
macro_rules! pending {
1717
() => {
18-
await!($crate::async_await::pending_once())
18+
$crate::async_await::pending_once().await
1919
}
2020
}
2121

futures-util/src/async_await/poll.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use futures_core::task::{Context, Poll};
1111
#[macro_export]
1212
macro_rules! poll {
1313
($x:expr) => {
14-
await!($crate::async_await::poll($x))
14+
$crate::async_await::poll($x).await
1515
}
1616
}
1717

futures-util/src/async_await/select_mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ macro_rules! document_select_macro {
2626
/// # Examples
2727
///
2828
/// ```
29-
/// #![feature(async_await, await_macro)]
29+
/// #![feature(async_await)]
3030
/// # futures::executor::block_on(async {
3131
/// use futures::future::{self, FutureExt};
3232
/// use futures::select;
@@ -42,7 +42,7 @@ macro_rules! document_select_macro {
4242
/// ```
4343
///
4444
/// ```
45-
/// #![feature(async_await, await_macro)]
45+
/// #![feature(async_await)]
4646
/// # futures::executor::block_on(async {
4747
/// use futures::future::{self, FutureExt};
4848
/// use futures::stream::{self, StreamExt};
@@ -64,7 +64,7 @@ macro_rules! document_select_macro {
6464
/// the case where all futures have completed.
6565
///
6666
/// ```
67-
/// #![feature(async_await, await_macro)]
67+
/// #![feature(async_await)]
6868
/// # futures::executor::block_on(async {
6969
/// use futures::future::{self, FutureExt};
7070
/// use futures::select;

futures-util/src/compat/compat01as03.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ pub trait Future01CompatExt: Future01 {
5252
/// [`Future<Output = Result<T, E>>`](futures_core::future::Future).
5353
///
5454
/// ```
55-
/// #![feature(async_await, await_macro)]
55+
/// #![feature(async_await)]
5656
/// # futures::executor::block_on(async {
5757
/// # // TODO: These should be all using `futures::compat`, but that runs up against Cargo
5858
/// # // feature issues
5959
/// use futures_util::compat::Future01CompatExt;
6060
///
6161
/// let future = futures_01::future::ok::<u32, ()>(1);
62-
/// assert_eq!(await!(future.compat()), Ok(1));
62+
/// assert_eq!(future.compat().await, Ok(1));
6363
/// # });
6464
/// ```
6565
fn compat(self) -> Compat01As03<Self>
@@ -79,15 +79,15 @@ pub trait Stream01CompatExt: Stream01 {
7979
/// [`Stream<Item = Result<T, E>>`](futures_core::stream::Stream).
8080
///
8181
/// ```
82-
/// #![feature(async_await, await_macro)]
82+
/// #![feature(async_await)]
8383
/// # futures::executor::block_on(async {
8484
/// use futures::stream::StreamExt;
8585
/// use futures_util::compat::Stream01CompatExt;
8686
///
8787
/// let stream = futures_01::stream::once::<u32, ()>(Ok(1));
8888
/// let mut stream = stream.compat();
89-
/// assert_eq!(await!(stream.next()), Some(Ok(1)));
90-
/// assert_eq!(await!(stream.next()), None);
89+
/// assert_eq!(stream.next().await, Some(Ok(1)));
90+
/// assert_eq!(stream.next().await, None);
9191
/// # });
9292
/// ```
9393
fn compat(self) -> Compat01As03<Self>
@@ -107,18 +107,18 @@ pub trait Sink01CompatExt: Sink01 {
107107
/// [`Sink<SinkItem = T, SinkError = E>`](futures_sink::sink::Sink).
108108
///
109109
/// ```
110-
/// #![feature(async_await, await_macro)]
110+
/// #![feature(async_await)]
111111
/// # futures::executor::block_on(async {
112112
/// use futures::{sink::SinkExt, stream::StreamExt};
113113
/// use futures_util::compat::{Stream01CompatExt, Sink01CompatExt};
114114
///
115115
/// let (tx, rx) = futures_01::unsync::mpsc::channel(1);
116116
/// let (mut tx, mut rx) = (tx.sink_compat(), rx.compat());
117117
///
118-
/// await!(tx.send(1)).unwrap();
118+
/// tx.send(1).await.unwrap();
119119
/// drop(tx);
120-
/// assert_eq!(await!(rx.next()), Some(Ok(1)));
121-
/// assert_eq!(await!(rx.next()), None);
120+
/// assert_eq!(rx.next().await, Some(Ok(1)));
121+
/// assert_eq!(rx.next().await, None);
122122
/// # });
123123
/// ```
124124
fn sink_compat(self) -> Compat01As03Sink<Self, Self::SinkItem>
@@ -356,7 +356,7 @@ mod io {
356356
/// [`AsyncRead`](futures_io::AsyncRead).
357357
///
358358
/// ```
359-
/// #![feature(async_await, await_macro, impl_trait_in_bindings)]
359+
/// #![feature(async_await, impl_trait_in_bindings)]
360360
/// # futures::executor::block_on(async {
361361
/// use futures::io::AsyncReadExt;
362362
/// use futures_util::compat::AsyncRead01CompatExt;
@@ -366,7 +366,7 @@ mod io {
366366
/// let mut reader: impl futures::io::AsyncRead + Unpin = reader.compat();
367367
///
368368
/// let mut output = Vec::with_capacity(12);
369-
/// await!(reader.read_to_end(&mut output)).unwrap();
369+
/// reader.read_to_end(&mut output).await.unwrap();
370370
/// assert_eq!(output, input);
371371
/// # });
372372
/// ```
@@ -385,7 +385,7 @@ mod io {
385385
/// [`AsyncWrite`](futures_io::AsyncWrite).
386386
///
387387
/// ```
388-
/// #![feature(async_await, await_macro, impl_trait_in_bindings)]
388+
/// #![feature(async_await, impl_trait_in_bindings)]
389389
/// # futures::executor::block_on(async {
390390
/// use futures::io::AsyncWriteExt;
391391
/// use futures_util::compat::AsyncWrite01CompatExt;
@@ -394,7 +394,7 @@ mod io {
394394
/// let mut cursor = std::io::Cursor::new(Vec::with_capacity(12));
395395
///
396396
/// let mut writer = (&mut cursor).compat();
397-
/// await!(writer.write_all(input)).unwrap();
397+
/// writer.write_all(input).await.unwrap();
398398
///
399399
/// assert_eq!(cursor.into_inner(), input);
400400
/// # });

futures-util/src/compat/executor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub trait Executor01CompatExt: Executor01<Executor01Future> +
2222
/// futures 0.3 [`Spawn`](futures_core::task::Spawn).
2323
///
2424
/// ```
25-
/// #![feature(async_await, await_macro)]
25+
/// #![feature(async_await)]
2626
/// use futures::Future;
2727
/// use futures::task::SpawnExt;
2828
/// use futures::future::{FutureExt, TryFutureExt};

futures-util/src/future/empty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ impl<T> FusedFuture for Empty<T> {
2222
/// # Examples
2323
///
2424
/// ```ignore
25-
/// #![feature(async_await, await_macro)]
25+
/// #![feature(async_await)]
2626
/// # futures::executor::block_on(async {
2727
/// use futures::future;
2828
///
2929
/// let future = future::empty();
30-
/// let () = await!(future);
30+
/// let () = future.await;
3131
/// unreachable!();
3232
/// # });
3333
/// ```

futures-util/src/future/fuse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<Fut: Future> Fuse<Fut> {
2727
/// # Examples
2828
///
2929
/// ```
30-
/// #![feature(async_await, await_macro, futures_api)]
30+
/// #![feature(async_await, futures_api)]
3131
/// # futures::executor::block_on(async {
3232
/// use futures::channel::mpsc;
3333
/// use futures::future::{Fuse, FusedFuture, FutureExt};

futures-util/src/future/join.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ generate! {
9090
/// # Examples
9191
///
9292
/// ```
93-
/// #![feature(async_await, await_macro)]
93+
/// #![feature(async_await)]
9494
/// # futures::executor::block_on(async {
9595
/// use futures::future;
9696
///
9797
/// let a = future::ready(1);
9898
/// let b = future::ready(2);
9999
/// let pair = future::join(a, b);
100100
///
101-
/// assert_eq!(await!(pair), (1, 2));
101+
/// assert_eq!(pair.await, (1, 2));
102102
/// # });
103103
/// ```
104104
pub fn join<Fut1, Fut2>(future1: Fut1, future2: Fut2) -> Join<Fut1, Fut2>
@@ -115,7 +115,7 @@ where
115115
/// # Examples
116116
///
117117
/// ```
118-
/// #![feature(async_await, await_macro)]
118+
/// #![feature(async_await)]
119119
/// # futures::executor::block_on(async {
120120
/// use futures::future;
121121
///
@@ -124,7 +124,7 @@ where
124124
/// let c = future::ready(3);
125125
/// let tuple = future::join3(a, b, c);
126126
///
127-
/// assert_eq!(await!(tuple), (1, 2, 3));
127+
/// assert_eq!(tuple.await, (1, 2, 3));
128128
/// # });
129129
/// ```
130130
pub fn join3<Fut1, Fut2, Fut3>(
@@ -145,7 +145,7 @@ where
145145
/// # Examples
146146
///
147147
/// ```
148-
/// #![feature(async_await, await_macro)]
148+
/// #![feature(async_await)]
149149
/// # futures::executor::block_on(async {
150150
/// use futures::future;
151151
///
@@ -155,7 +155,7 @@ where
155155
/// let d = future::ready(4);
156156
/// let tuple = future::join4(a, b, c, d);
157157
///
158-
/// assert_eq!(await!(tuple), (1, 2, 3, 4));
158+
/// assert_eq!(tuple.await, (1, 2, 3, 4));
159159
/// # });
160160
/// ```
161161
pub fn join4<Fut1, Fut2, Fut3, Fut4>(
@@ -179,7 +179,7 @@ where
179179
/// # Examples
180180
///
181181
/// ```
182-
/// #![feature(async_await, await_macro)]
182+
/// #![feature(async_await)]
183183
/// # futures::executor::block_on(async {
184184
/// use futures::future;
185185
///
@@ -190,7 +190,7 @@ where
190190
/// let e = future::ready(5);
191191
/// let tuple = future::join5(a, b, c, d, e);
192192
///
193-
/// assert_eq!(await!(tuple), (1, 2, 3, 4, 5));
193+
/// assert_eq!(tuple.await, (1, 2, 3, 4, 5));
194194
/// # });
195195
/// ```
196196
pub fn join5<Fut1, Fut2, Fut3, Fut4, Fut5>(

futures-util/src/future/join_all.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ where
9999
/// # Examples
100100
///
101101
/// ```
102-
/// #![feature(async_await, await_macro)]
102+
/// #![feature(async_await)]
103103
/// # futures::executor::block_on(async {
104104
/// use futures::future::{join_all};
105105
///
106106
/// async fn foo(i: u32) -> u32 { i }
107107
///
108108
/// let futures = vec![foo(1), foo(2), foo(3)];
109109
///
110-
/// assert_eq!(await!(join_all(futures)), [1, 2, 3]);
110+
/// assert_eq!(join_all(futures).await, [1, 2, 3]);
111111
/// # });
112112
/// ```
113113
pub fn join_all<I>(i: I) -> JoinAll<I::Item>

futures-util/src/future/lazy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ impl<F> Unpin for Lazy<F> {}
1919
/// # Examples
2020
///
2121
/// ```
22-
/// #![feature(async_await, await_macro)]
22+
/// #![feature(async_await)]
2323
/// # futures::executor::block_on(async {
2424
/// use futures::future;
2525
///
2626
/// let a = future::lazy(|_| 1);
27-
/// assert_eq!(await!(a), 1);
27+
/// assert_eq!(a.await, 1);
2828
///
2929
/// let b = future::lazy(|_| -> i32 {
3030
/// panic!("oh no!")

0 commit comments

Comments
 (0)