Skip to content

Commit

Permalink
Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Oct 22, 2019
1 parent cde60e8 commit 4fcc784
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/librustc/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2135,13 +2135,13 @@ Erroneous code examples:
# use std::pin::Pin;
# use std::future::Future;
# use std::task::{Context, Poll};
#
# struct WakeOnceThenComplete(bool);
#
# fn wake_and_yield_once() -> WakeOnceThenComplete {
# WakeOnceThenComplete(false)
# }
#
# impl Future for WakeOnceThenComplete {
# type Output = ();
# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
Expand All @@ -2154,7 +2154,7 @@ Erroneous code examples:
# }
# }
# }
#
fn foo() {
wake_and_yield_once().await // `await` is used outside `async` context
}
Expand All @@ -2168,13 +2168,13 @@ an async context, like an `async fn` or an `async` block.
# use std::pin::Pin;
# use std::future::Future;
# use std::task::{Context, Poll};
#
# struct WakeOnceThenComplete(bool);
#
# fn wake_and_yield_once() -> WakeOnceThenComplete {
# WakeOnceThenComplete(false)
# }
#
# impl Future for WakeOnceThenComplete {
# type Output = ();
# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
Expand All @@ -2187,9 +2187,16 @@ an async context, like an `async fn` or an `async` block.
# }
# }
# }
#
async fn foo() {
wake_and_yield_once().await // `await` is used within `async` context
wake_and_yield_once().await // `await` is used within `async` function
}
fn bar(x: u8) -> impl Future<Output = u8> {
async move {
wake_and_yield_once().await; // `await` is used within `async` block
x
}
}
```
"##,
Expand Down

0 comments on commit 4fcc784

Please sign in to comment.