Skip to content

Commit b0d4782

Browse files
committed
Stabilize 'async_await'.
1 parent c1b08dd commit b0d4782

File tree

5 files changed

+4
-28
lines changed

5 files changed

+4
-28
lines changed

src/librustc/error_codes.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,6 @@ generator can be constructed.
20882088
Erroneous code example:
20892089
20902090
```edition2018,compile-fail,E0698
2091-
#![feature(async_await)]
20922091
async fn bar<T>() -> () {}
20932092
20942093
async fn foo() {
@@ -2101,7 +2100,6 @@ To fix this you must bind `T` to a concrete type such as `String`
21012100
so that a generator can then be constructed:
21022101
21032102
```edition2018
2104-
#![feature(async_await)]
21052103
async fn bar<T>() -> () {}
21062104
21072105
async fn foo() {

src/librustc_typeck/check/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -4197,8 +4197,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
41974197
/// A possible error is to forget to add `.await` when using futures:
41984198
///
41994199
/// ```
4200-
/// #![feature(async_await)]
4201-
///
42024200
/// async fn make_u32() -> u32 {
42034201
/// 22
42044202
/// }

src/librustc_typeck/error_codes.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -4751,7 +4751,6 @@ E0733: r##"
47514751
Recursion in an `async fn` requires boxing. For example, this will not compile:
47524752
47534753
```edition2018,compile_fail,E0733
4754-
#![feature(async_await)]
47554754
async fn foo(n: usize) {
47564755
if n > 0 {
47574756
foo(n - 1).await;
@@ -4763,12 +4762,11 @@ To achieve async recursion, the `async fn` needs to be desugared
47634762
such that the `Future` is explicit in the return type:
47644763
47654764
```edition2018,compile_fail,E0720
4766-
# #![feature(async_await)]
47674765
use std::future::Future;
4768-
fn foo_desugered(n: usize) -> impl Future<Output = ()> {
4766+
fn foo_desugared(n: usize) -> impl Future<Output = ()> {
47694767
async move {
47704768
if n > 0 {
4771-
foo_desugered(n - 1).await;
4769+
foo_desugared(n - 1).await;
47724770
}
47734771
}
47744772
}
@@ -4777,7 +4775,6 @@ fn foo_desugered(n: usize) -> impl Future<Output = ()> {
47774775
Finally, the future is wrapped in a pinned box:
47784776
47794777
```edition2018
4780-
# #![feature(async_await)]
47814778
use std::future::Future;
47824779
use std::pin::Pin;
47834780
fn foo_recursive(n: usize) -> Pin<Box<dyn Future<Output = ()>>> {

src/libstd/keyword_docs.rs

-2
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,6 @@ mod where_keyword { }
984984

985985
// 2018 Edition keywords
986986

987-
#[unstable(feature = "async_await", issue = "50547")]
988987
#[doc(keyword = "async")]
989988
//
990989
/// Return a [`Future`] instead of blocking the current thread.
@@ -995,7 +994,6 @@ mod where_keyword { }
995994
/// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
996995
mod async_keyword { }
997996

998-
#[unstable(feature = "async_await", issue = "50547")]
999997
#[doc(keyword = "await")]
1000998
//
1001999
/// Suspend execution until the result of a [`Future`] is ready.

src/libsyntax/feature_gate.rs

+2-17
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,6 @@ declare_features! (
461461
// Allows using `#[doc(keyword = "...")]`.
462462
(active, doc_keyword, "1.28.0", Some(51315), None),
463463

464-
// Allows async and await syntax.
465-
(active, async_await, "1.28.0", Some(50547), None),
466-
467464
// Allows reinterpretation of the bits of a value of one type as another type during const eval.
468465
(active, const_transmute, "1.29.0", Some(53605), None),
469466

@@ -857,6 +854,8 @@ declare_features! (
857854
(accepted, repr_align_enum, "1.37.0", Some(57996), None),
858855
// Allows `const _: TYPE = VALUE`.
859856
(accepted, underscore_const_names, "1.37.0", Some(54912), None),
857+
// Allows free and inherent `async fn`s, `async` blocks, and `<expr>.await` expressions.
858+
(accepted, async_await, "1.38.0", Some(50547), None),
860859

861860
// -------------------------------------------------------------------------
862861
// feature-group-end: accepted features
@@ -2100,12 +2099,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
21002099
"labels on blocks are unstable");
21012100
}
21022101
}
2103-
ast::ExprKind::Async(..) => {
2104-
gate_feature_post!(&self, async_await, e.span, "async blocks are unstable");
2105-
}
2106-
ast::ExprKind::Await(_) => {
2107-
gate_feature_post!(&self, async_await, e.span, "async/await is unstable");
2108-
}
21092102
_ => {}
21102103
}
21112104
visit::walk_expr(self, e)
@@ -2154,11 +2147,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
21542147
span: Span,
21552148
_node_id: NodeId) {
21562149
if let Some(header) = fn_kind.header() {
2157-
// Check for const fn and async fn declarations.
2158-
if header.asyncness.node.is_async() {
2159-
gate_feature_post!(&self, async_await, span, "async fn is unstable");
2160-
}
2161-
21622150
// Stability of const fn methods are covered in
21632151
// `visit_trait_item` and `visit_impl_item` below; this is
21642152
// because default methods don't pass through this point.
@@ -2198,9 +2186,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
21982186
if block.is_none() {
21992187
self.check_abi(sig.header.abi, ti.span);
22002188
}
2201-
if sig.header.asyncness.node.is_async() {
2202-
gate_feature_post!(&self, async_await, ti.span, "async fn is unstable");
2203-
}
22042189
if sig.decl.c_variadic {
22052190
gate_feature_post!(&self, c_variadic, ti.span,
22062191
"C-variadic functions are unstable");

0 commit comments

Comments
 (0)