@@ -2135,13 +2135,13 @@ Erroneous code examples:
21352135# use std::pin::Pin;
21362136# use std::future::Future;
21372137# use std::task::{Context, Poll};
2138-
2138+ #
21392139# struct WakeOnceThenComplete(bool);
2140-
2140+ #
21412141# fn wake_and_yield_once() -> WakeOnceThenComplete {
21422142# WakeOnceThenComplete(false)
21432143# }
2144-
2144+ #
21452145# impl Future for WakeOnceThenComplete {
21462146# type Output = ();
21472147# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
@@ -2154,7 +2154,7 @@ Erroneous code examples:
21542154# }
21552155# }
21562156# }
2157-
2157+ #
21582158fn foo() {
21592159 wake_and_yield_once().await // `await` is used outside `async` context
21602160}
@@ -2168,13 +2168,13 @@ an async context, like an `async fn` or an `async` block.
21682168# use std::pin::Pin;
21692169# use std::future::Future;
21702170# use std::task::{Context, Poll};
2171-
2171+ #
21722172# struct WakeOnceThenComplete(bool);
2173-
2173+ #
21742174# fn wake_and_yield_once() -> WakeOnceThenComplete {
21752175# WakeOnceThenComplete(false)
21762176# }
2177-
2177+ #
21782178# impl Future for WakeOnceThenComplete {
21792179# type Output = ();
21802180# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
@@ -2187,9 +2187,16 @@ an async context, like an `async fn` or an `async` block.
21872187# }
21882188# }
21892189# }
2190-
2190+ #
21912191async fn foo() {
2192- wake_and_yield_once().await // `await` is used within `async` context
2192+ wake_and_yield_once().await // `await` is used within `async` function
2193+ }
2194+
2195+ fn bar(x: u8) -> impl Future<Output = u8> {
2196+ async move {
2197+ wake_and_yield_once().await; // `await` is used within `async` block
2198+ x
2199+ }
21932200}
21942201```
21952202"## ,
0 commit comments