-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Implement built-in await syntax #60586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
// edition:2018 | ||
// aux-build:arc_wake.rs | ||
|
||
#![feature(async_await, await_macro)] | ||
|
||
extern crate arc_wake; | ||
|
||
use std::pin::Pin; | ||
use std::future::Future; | ||
use std::sync::{ | ||
Arc, | ||
atomic::{self, AtomicUsize}, | ||
}; | ||
use std::task::{Context, Poll}; | ||
use arc_wake::ArcWake; | ||
|
||
struct Counter { | ||
wakes: AtomicUsize, | ||
} | ||
|
||
impl ArcWake for Counter { | ||
fn wake(self: Arc<Self>) { | ||
Self::wake_by_ref(&self) | ||
} | ||
fn wake_by_ref(arc_self: &Arc<Self>) { | ||
arc_self.wakes.fetch_add(1, atomic::Ordering::SeqCst); | ||
} | ||
} | ||
|
||
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<()> { | ||
if self.0 { | ||
Poll::Ready(()) | ||
} else { | ||
cx.waker().wake_by_ref(); | ||
self.0 = true; | ||
Poll::Pending | ||
} | ||
} | ||
} | ||
|
||
fn async_block(x: u8) -> impl Future<Output = u8> { | ||
async move { | ||
await!(wake_and_yield_once()); | ||
x | ||
} | ||
} | ||
|
||
fn async_block_with_borrow_named_lifetime<'a>(x: &'a u8) -> impl Future<Output = u8> + 'a { | ||
async move { | ||
await!(wake_and_yield_once()); | ||
*x | ||
} | ||
} | ||
|
||
fn async_nonmove_block(x: u8) -> impl Future<Output = u8> { | ||
async move { | ||
let future = async { | ||
await!(wake_and_yield_once()); | ||
x | ||
}; | ||
await!(future) | ||
} | ||
} | ||
|
||
fn async_closure(x: u8) -> impl Future<Output = u8> { | ||
(async move |x: u8| -> u8 { | ||
await!(wake_and_yield_once()); | ||
x | ||
})(x) | ||
} | ||
|
||
async fn async_fn(x: u8) -> u8 { | ||
await!(wake_and_yield_once()); | ||
x | ||
} | ||
|
||
async fn generic_async_fn<T>(x: T) -> T { | ||
await!(wake_and_yield_once()); | ||
x | ||
} | ||
|
||
async fn async_fn_with_borrow(x: &u8) -> u8 { | ||
await!(wake_and_yield_once()); | ||
*x | ||
} | ||
|
||
async fn async_fn_with_borrow_named_lifetime<'a>(x: &'a u8) -> u8 { | ||
await!(wake_and_yield_once()); | ||
*x | ||
} | ||
|
||
fn async_fn_with_impl_future_named_lifetime<'a>(x: &'a u8) -> impl Future<Output = u8> + 'a { | ||
async move { | ||
await!(wake_and_yield_once()); | ||
*x | ||
} | ||
} | ||
|
||
/* FIXME(cramertj) support when `existential type T<'a, 'b>:;` works | ||
async fn async_fn_multiple_args(x: &u8, _y: &u8) -> u8 { | ||
await!(wake_and_yield_once()); | ||
*x | ||
} | ||
*/ | ||
|
||
async fn async_fn_multiple_args_named_lifetime<'a>(x: &'a u8, _y: &'a u8) -> u8 { | ||
await!(wake_and_yield_once()); | ||
*x | ||
} | ||
|
||
fn async_fn_with_internal_borrow(y: u8) -> impl Future<Output = u8> { | ||
async move { | ||
await!(async_fn_with_borrow_named_lifetime(&y)) | ||
} | ||
} | ||
|
||
unsafe async fn unsafe_async_fn(x: u8) -> u8 { | ||
await!(wake_and_yield_once()); | ||
x | ||
} | ||
|
||
struct Foo; | ||
|
||
trait Bar { | ||
fn foo() {} | ||
} | ||
|
||
impl Foo { | ||
async fn async_method(x: u8) -> u8 { | ||
unsafe { | ||
await!(unsafe_async_fn(x)) | ||
} | ||
} | ||
} | ||
|
||
fn test_future_yields_once_then_returns<F, Fut>(f: F) | ||
where | ||
F: FnOnce(u8) -> Fut, | ||
Fut: Future<Output = u8>, | ||
{ | ||
let mut fut = Box::pin(f(9)); | ||
let counter = Arc::new(Counter { wakes: AtomicUsize::new(0) }); | ||
let waker = ArcWake::into_waker(counter.clone()); | ||
let mut cx = Context::from_waker(&waker); | ||
assert_eq!(0, counter.wakes.load(atomic::Ordering::SeqCst)); | ||
assert_eq!(Poll::Pending, fut.as_mut().poll(&mut cx)); | ||
assert_eq!(1, counter.wakes.load(atomic::Ordering::SeqCst)); | ||
assert_eq!(Poll::Ready(9), fut.as_mut().poll(&mut cx)); | ||
} | ||
|
||
fn main() { | ||
macro_rules! test { | ||
($($fn_name:expr,)*) => { $( | ||
test_future_yields_once_then_returns($fn_name); | ||
)* } | ||
} | ||
|
||
macro_rules! test_with_borrow { | ||
($($fn_name:expr,)*) => { $( | ||
test_future_yields_once_then_returns(|x| { | ||
async move { | ||
await!($fn_name(&x)) | ||
} | ||
}); | ||
)* } | ||
} | ||
|
||
test! { | ||
async_block, | ||
async_nonmove_block, | ||
async_closure, | ||
async_fn, | ||
generic_async_fn, | ||
async_fn_with_internal_borrow, | ||
Foo::async_method, | ||
|x| { | ||
async move { | ||
unsafe { await!(unsafe_async_fn(x)) } | ||
} | ||
}, | ||
} | ||
test_with_borrow! { | ||
async_block_with_borrow_named_lifetime, | ||
async_fn_with_borrow, | ||
async_fn_with_borrow_named_lifetime, | ||
async_fn_with_impl_future_named_lifetime, | ||
|x| { | ||
async move { | ||
await!(async_fn_multiple_args_named_lifetime(x, x)) | ||
} | ||
}, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#![feature(async_await, await_macro)] | ||
#![allow(non_camel_case_types)] | ||
#![deny(keyword_idents)] | ||
|
||
mod outer_mod { | ||
cramertj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pub mod await { //~ ERROR `await` is a keyword in the 2018 edition | ||
//~^ WARN this was previously accepted by the compiler | ||
pub struct await; //~ ERROR `await` is a keyword in the 2018 edition | ||
//~^ WARN this was previously accepted by the compiler | ||
} | ||
} | ||
use outer_mod::await::await; //~ ERROR `await` is a keyword in the 2018 edition | ||
//~^ ERROR `await` is a keyword in the 2018 edition | ||
//~^^ WARN this was previously accepted by the compiler | ||
//~^^^ WARN this was previously accepted by the compiler | ||
|
||
struct Foo { await: () } | ||
//~^ ERROR `await` is a keyword in the 2018 edition | ||
//~^^ WARN this was previously accepted by the compiler | ||
|
||
impl Foo { fn await() {} } | ||
//~^ ERROR `await` is a keyword in the 2018 edition | ||
//~^^ WARN this was previously accepted by the compiler | ||
|
||
macro_rules! await { | ||
//~^ ERROR `await` is a keyword in the 2018 edition | ||
//~^^ WARN this was previously accepted by the compiler | ||
() => {} | ||
} | ||
|
||
fn main() { | ||
match await { await => {} } //~ ERROR `await` is a keyword in the 2018 edition | ||
//~^ ERROR `await` is a keyword in the 2018 edition | ||
//~^^ WARN this was previously accepted by the compiler | ||
//~^^^ WARN this was previously accepted by the compiler | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-error-in-non-macro-position.rs:6:13 | ||
| | ||
LL | pub mod await { | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
note: lint level defined here | ||
--> $DIR/2015-edition-error-in-non-macro-position.rs:3:9 | ||
| | ||
LL | #![deny(keyword_idents)] | ||
| ^^^^^^^^^^^^^^ | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-error-in-non-macro-position.rs:8:20 | ||
| | ||
LL | pub struct await; | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-error-in-non-macro-position.rs:12:16 | ||
| | ||
LL | use outer_mod::await::await; | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-error-in-non-macro-position.rs:12:23 | ||
| | ||
LL | use outer_mod::await::await; | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-error-in-non-macro-position.rs:17:14 | ||
| | ||
LL | struct Foo { await: () } | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-error-in-non-macro-position.rs:21:15 | ||
| | ||
LL | impl Foo { fn await() {} } | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-error-in-non-macro-position.rs:25:14 | ||
| | ||
LL | macro_rules! await { | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-error-in-non-macro-position.rs:32:11 | ||
| | ||
LL | match await { await => {} } | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-error-in-non-macro-position.rs:32:19 | ||
| | ||
LL | match await { await => {} } | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: aborting due to 9 previous errors | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// edition:2018 | ||
|
||
#![allow(non_camel_case_types)] | ||
#![feature(async_await, await_macro)] | ||
|
||
mod outer_mod { | ||
pub mod await { //~ ERROR expected identifier, found reserved keyword `await` | ||
pub struct await; //~ ERROR expected identifier, found reserved keyword `await` | ||
} | ||
} | ||
use self::outer_mod::await::await; //~ ERROR expected identifier, found reserved keyword `await` | ||
//~^ ERROR expected identifier, found reserved keyword `await` | ||
|
||
struct Foo { await: () } | ||
//~^ ERROR expected identifier, found reserved keyword `await` | ||
|
||
impl Foo { fn await() {} } | ||
//~^ ERROR expected identifier, found reserved keyword `await` | ||
|
||
macro_rules! await { | ||
//~^ ERROR expected identifier, found reserved keyword `await` | ||
() => {} | ||
} | ||
|
||
fn main() { | ||
match await { await => () } //~ ERROR expected `!`, found `{` | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
error: expected identifier, found reserved keyword `await` | ||
--> $DIR/2018-edition-error-in-non-macro-position.rs:7:13 | ||
| | ||
LL | pub mod await { | ||
| ^^^^^ expected identifier, found reserved keyword | ||
help: you can escape reserved keywords to use them as identifiers | ||
| | ||
LL | pub mod r#await { | ||
| ^^^^^^^ | ||
|
||
error: expected identifier, found reserved keyword `await` | ||
--> $DIR/2018-edition-error-in-non-macro-position.rs:8:20 | ||
| | ||
LL | pub struct await; | ||
| ^^^^^ expected identifier, found reserved keyword | ||
help: you can escape reserved keywords to use them as identifiers | ||
| | ||
LL | pub struct r#await; | ||
| ^^^^^^^ | ||
|
||
error: expected identifier, found reserved keyword `await` | ||
--> $DIR/2018-edition-error-in-non-macro-position.rs:11:22 | ||
| | ||
LL | use self::outer_mod::await::await; | ||
| ^^^^^ expected identifier, found reserved keyword | ||
help: you can escape reserved keywords to use them as identifiers | ||
| | ||
LL | use self::outer_mod::r#await::await; | ||
| ^^^^^^^ | ||
|
||
error: expected identifier, found reserved keyword `await` | ||
--> $DIR/2018-edition-error-in-non-macro-position.rs:11:29 | ||
| | ||
LL | use self::outer_mod::await::await; | ||
| ^^^^^ expected identifier, found reserved keyword | ||
help: you can escape reserved keywords to use them as identifiers | ||
| | ||
LL | use self::outer_mod::await::r#await; | ||
| ^^^^^^^ | ||
|
||
error: expected identifier, found reserved keyword `await` | ||
--> $DIR/2018-edition-error-in-non-macro-position.rs:14:14 | ||
| | ||
LL | struct Foo { await: () } | ||
| ^^^^^ expected identifier, found reserved keyword | ||
help: you can escape reserved keywords to use them as identifiers | ||
| | ||
LL | struct Foo { r#await: () } | ||
| ^^^^^^^ | ||
|
||
error: expected identifier, found reserved keyword `await` | ||
--> $DIR/2018-edition-error-in-non-macro-position.rs:17:15 | ||
| | ||
LL | impl Foo { fn await() {} } | ||
| ^^^^^ expected identifier, found reserved keyword | ||
help: you can escape reserved keywords to use them as identifiers | ||
| | ||
LL | impl Foo { fn r#await() {} } | ||
| ^^^^^^^ | ||
|
||
error: expected identifier, found reserved keyword `await` | ||
--> $DIR/2018-edition-error-in-non-macro-position.rs:20:14 | ||
| | ||
LL | macro_rules! await { | ||
| ^^^^^ expected identifier, found reserved keyword | ||
help: you can escape reserved keywords to use them as identifiers | ||
| | ||
LL | macro_rules! r#await { | ||
| ^^^^^^^ | ||
|
||
error: expected `!`, found `{` | ||
--> $DIR/2018-edition-error-in-non-macro-position.rs:26:17 | ||
| | ||
LL | match await { await => () } | ||
| ----- ^ expected `!` | ||
| | | ||
| while parsing this match expression | ||
|
||
error: aborting due to 8 previous errors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,50 @@ | ||
error[E0721]: `await` is a keyword in the 2018 edition | ||
error: expected identifier, found reserved keyword `await` | ||
--> $DIR/2018-edition-error.rs:5:13 | ||
| | ||
LL | pub mod await { | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| ^^^^^ expected identifier, found reserved keyword | ||
help: you can escape reserved keywords to use them as identifiers | ||
| | ||
LL | pub mod r#await { | ||
| ^^^^^^^ | ||
|
||
error[E0721]: `await` is a keyword in the 2018 edition | ||
error: expected identifier, found reserved keyword `await` | ||
--> $DIR/2018-edition-error.rs:6:20 | ||
| | ||
LL | pub struct await; | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| ^^^^^ expected identifier, found reserved keyword | ||
help: you can escape reserved keywords to use them as identifiers | ||
| | ||
LL | pub struct r#await; | ||
| ^^^^^^^ | ||
|
||
error[E0721]: `await` is a keyword in the 2018 edition | ||
error: expected identifier, found reserved keyword `await` | ||
--> $DIR/2018-edition-error.rs:9:22 | ||
| | ||
LL | use self::outer_mod::await::await; | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| ^^^^^ expected identifier, found reserved keyword | ||
help: you can escape reserved keywords to use them as identifiers | ||
| | ||
LL | use self::outer_mod::r#await::await; | ||
| ^^^^^^^ | ||
|
||
error[E0721]: `await` is a keyword in the 2018 edition | ||
error: expected identifier, found reserved keyword `await` | ||
--> $DIR/2018-edition-error.rs:9:29 | ||
| | ||
LL | use self::outer_mod::await::await; | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
|
||
error[E0721]: `await` is a keyword in the 2018 edition | ||
--> $DIR/2018-edition-error.rs:13:11 | ||
| ^^^^^ expected identifier, found reserved keyword | ||
help: you can escape reserved keywords to use them as identifiers | ||
| | ||
LL | match await { await => () } | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
LL | use self::outer_mod::await::r#await; | ||
| ^^^^^^^ | ||
|
||
error[E0721]: `await` is a keyword in the 2018 edition | ||
--> $DIR/2018-edition-error.rs:13:19 | ||
error: expected `!`, found `{` | ||
--> $DIR/2018-edition-error.rs:13:17 | ||
| | ||
LL | match await { await => () } | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| ----- ^ expected `!` | ||
| | | ||
| while parsing this match expression | ||
|
||
error: aborting due to 6 previous errors | ||
error: aborting due to 5 previous errors | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
error[E0721]: `await` is a keyword in the 2018 edition | ||
--> $DIR/post_expansion_error.rs:8:5 | ||
error: expected expression, found `)` | ||
--> $DIR/post_expansion_error.rs:8:12 | ||
| | ||
LL | await!() | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| ^ expected expression | ||
|
||
error: aborting due to previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// gate-test-await_macro | ||
// edition:2018 | ||
|
||
#![feature(async_await)] | ||
|
||
async fn bar() {} | ||
|
||
async fn foo() { | ||
await!(bar()); //~ ERROR `await!(<expr>)` macro syntax is unstable, and will soon be removed | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0658]: `await!(<expr>)` macro syntax is unstable, and will soon be removed in favor of `<expr>.await` syntax. | ||
--> $DIR/await-macro.rs:9:5 | ||
| | ||
LL | await!(bar()); | ||
| ^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/50547 | ||
= help: add #![feature(await_macro)] to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
error[E0698]: type inside generator must be known in this context | ||
--> $DIR/unresolved_type_param.rs:9:16 | ||
--> $DIR/unresolved_type_param.rs:9:5 | ||
| | ||
LL | await!(bar()); | ||
| ^^^ cannot infer type for `T` | ||
LL | bar().await; | ||
| ^^^ cannot infer type for `T` | ||
| | ||
note: the type is part of the generator because of this `yield` | ||
--> $DIR/unresolved_type_param.rs:9:9 | ||
--> $DIR/unresolved_type_param.rs:9:5 | ||
| | ||
LL | await!(bar()); | ||
| ^^^^^^^^^^^^^^ | ||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
LL | bar().await; | ||
| ^^^^^^^^^^^ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👀 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened #60615 |
||
|
||
error: aborting due to previous error | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// edition:2018 | ||
// | ||
// Tests that the .await syntax can't be used to make a generator | ||
|
||
#![feature(async_await)] | ||
|
||
async fn foo() {} | ||
|
||
fn make_generator() { | ||
let _gen = || foo.await; //~ ERROR `await` is only allowed inside `async` functions and blocks | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error[E0728]: `await` is only allowed inside `async` functions and blocks | ||
--> $DIR/issue-51719.rs:10:19 | ||
| | ||
LL | let _gen = || foo.await; | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// edition:2018 | ||
|
||
#![feature(async_await)] | ||
|
||
async fn inc(limit: i64) -> i64 { | ||
limit + 1 | ||
} | ||
|
||
fn main() { | ||
let result = inc(10000); | ||
let finished = result.await; | ||
//~^ ERROR `await` is only allowed inside `async` functions and blocks | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error[E0728]: `await` is only allowed inside `async` functions and blocks | ||
--> $DIR/issue-51751.rs:11:20 | ||
| | ||
LL | let finished = result.await; | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
Uh oh!
There was an error while loading. Please reload this page.