Skip to content

Commit c605c84

Browse files
Stabilize async closures
1 parent d4025ee commit c605c84

File tree

184 files changed

+311
-553
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+311
-553
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
511511
"you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`"
512512
);
513513
gate_all!(let_chains, "`let` expressions in this position are unstable");
514-
gate_all!(
515-
async_closure,
516-
"async closures are unstable",
517-
"to use an async block, remove the `||`: `async {`"
518-
);
519514
gate_all!(
520515
async_trait_bounds,
521516
"`async` trait bounds are unstable",

compiler/rustc_error_codes/src/error_codes/E0708.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
Erroneous code example:
66

77
```edition2018
8-
#![feature(async_closure)]
9-
108
fn main() {
119
let add_one = async |num: u8| {
1210
num + 1
@@ -18,8 +16,6 @@ fn main() {
1816
version, you can use successfully by using move:
1917

2018
```edition2018
21-
#![feature(async_closure)]
22-
2319
fn main() {
2420
let add_one = async move |num: u8| { // ok!
2521
num + 1

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ declare_features! (
7272
(accepted, associated_types, "1.0.0", None),
7373
/// Allows free and inherent `async fn`s, `async` blocks, and `<expr>.await` expressions.
7474
(accepted, async_await, "1.39.0", Some(50547)),
75+
/// Allows `async || body` closures.
76+
(accepted, async_closure, "CURRENT_RUSTC_VERSION", Some(62290)),
7577
/// Allows async functions to be declared, implemented, and used in traits.
7678
(accepted, async_fn_in_trait, "1.75.0", Some(91611)),
7779
/// Allows all literals in attribute lists and values of key-value pairs.

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,6 @@ declare_features! (
388388
(unstable, associated_const_equality, "1.58.0", Some(92827)),
389389
/// Allows associated type defaults.
390390
(unstable, associated_type_defaults, "1.2.0", Some(29661)),
391-
/// Allows `async || body` closures.
392-
(unstable, async_closure, "1.37.0", Some(62290)),
393391
/// Allows async functions to be called from `dyn Trait`.
394392
(incomplete, async_fn_in_dyn_trait, "CURRENT_RUSTC_VERSION", Some(133119)),
395393
/// Allows `#[track_caller]` on async functions.

compiler/rustc_hir_typeck/src/upvar.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18401840
/// captured by move.
18411841
///
18421842
/// ```rust
1843-
/// #![feature(async_closure)]
18441843
/// let x = &1i32; // Let's call this lifetime `'1`.
18451844
/// let c = async move || {
18461845
/// println!("{:?}", *x);
@@ -1855,7 +1854,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18551854
/// child capture with the lifetime of the parent coroutine-closure's env.
18561855
///
18571856
/// ```rust
1858-
/// #![feature(async_closure)]
18591857
/// let mut x = 1i32;
18601858
/// let c = async || {
18611859
/// x = 1;

compiler/rustc_lint/src/async_closures.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ declare_lint! {
1212
/// ### Example
1313
///
1414
/// ```rust
15-
/// #![feature(async_closure)]
1615
/// #![warn(closure_returning_async_block)]
1716
/// let c = |x: &str| async {};
1817
/// ```
@@ -40,8 +39,6 @@ declare_lint! {
4039
/// But it does work with async closures:
4140
///
4241
/// ```rust
43-
/// #![feature(async_closure)]
44-
///
4542
/// async fn callback(x: &str) {}
4643
///
4744
/// let captured_str = String::new();
@@ -52,7 +49,6 @@ declare_lint! {
5249
pub CLOSURE_RETURNING_ASYNC_BLOCK,
5350
Allow,
5451
"closure that returns `async {}` could be rewritten as an async closure",
55-
@feature_gate = async_closure;
5652
}
5753

5854
declare_lint_pass!(

compiler/rustc_mir_transform/src/coroutine/by_move_body.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
//!
44
//! Consider an async closure like:
55
//! ```rust
6-
//! #![feature(async_closure)]
7-
//!
86
//! let x = vec![1, 2, 3];
97
//!
108
//! let closure = async move || {

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,10 +2366,7 @@ impl<'a> Parser<'a> {
23662366
};
23672367

23682368
match coroutine_kind {
2369-
Some(CoroutineKind::Async { span, .. }) => {
2370-
// Feature-gate `async ||` closures.
2371-
self.psess.gated_spans.gate(sym::async_closure, span);
2372-
}
2369+
Some(CoroutineKind::Async { .. }) => {}
23732370
Some(CoroutineKind::Gen { span, .. }) | Some(CoroutineKind::AsyncGen { span, .. }) => {
23742371
// Feature-gate `gen ||` and `async gen ||` closures.
23752372
// FIXME(gen_blocks): This perhaps should be a different gate.

library/alloc/src/boxed.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,7 +1985,8 @@ impl<Args: Tuple, F: Fn<Args> + ?Sized, A: Allocator> Fn<Args> for Box<F, A> {
19851985
}
19861986
}
19871987

1988-
#[unstable(feature = "async_fn_traits", issue = "none")]
1988+
#[cfg_attr(bootstrap, unstable(feature = "async_closure", issue = "62290"))]
1989+
#[cfg_attr(not(bootstrap), stable(feature = "async_closure", since = "CURRENT_RUSTC_VERSION"))]
19891990
impl<Args: Tuple, F: AsyncFnOnce<Args> + ?Sized, A: Allocator> AsyncFnOnce<Args> for Box<F, A> {
19901991
type Output = F::Output;
19911992
type CallOnceFuture = F::CallOnceFuture;
@@ -1995,7 +1996,8 @@ impl<Args: Tuple, F: AsyncFnOnce<Args> + ?Sized, A: Allocator> AsyncFnOnce<Args>
19951996
}
19961997
}
19971998

1998-
#[unstable(feature = "async_fn_traits", issue = "none")]
1999+
#[cfg_attr(bootstrap, unstable(feature = "async_closure", issue = "62290"))]
2000+
#[cfg_attr(not(bootstrap), stable(feature = "async_closure", since = "CURRENT_RUSTC_VERSION"))]
19992001
impl<Args: Tuple, F: AsyncFnMut<Args> + ?Sized, A: Allocator> AsyncFnMut<Args> for Box<F, A> {
20002002
type CallRefFuture<'a>
20012003
= F::CallRefFuture<'a>
@@ -2007,7 +2009,8 @@ impl<Args: Tuple, F: AsyncFnMut<Args> + ?Sized, A: Allocator> AsyncFnMut<Args> f
20072009
}
20082010
}
20092011

2010-
#[unstable(feature = "async_fn_traits", issue = "none")]
2012+
#[cfg_attr(bootstrap, unstable(feature = "async_closure", issue = "62290"))]
2013+
#[cfg_attr(not(bootstrap), stable(feature = "async_closure", since = "CURRENT_RUSTC_VERSION"))]
20112014
impl<Args: Tuple, F: AsyncFn<Args> + ?Sized, A: Allocator> AsyncFn<Args> for Box<F, A> {
20122015
extern "rust-call" fn async_call(&self, args: Args) -> Self::CallRefFuture<'_> {
20132016
F::async_call(self, args)

library/alloc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
//
9292
// Library features:
9393
// tidy-alphabetical-start
94+
#![cfg_attr(bootstrap, feature(async_closure))]
9495
#![cfg_attr(test, feature(str_as_str))]
9596
#![feature(alloc_layout_extra)]
9697
#![feature(allocator_api)]
@@ -99,7 +100,6 @@
99100
#![feature(array_windows)]
100101
#![feature(ascii_char)]
101102
#![feature(assert_matches)]
102-
#![feature(async_closure)]
103103
#![feature(async_fn_traits)]
104104
#![feature(async_iterator)]
105105
#![feature(box_uninit_write)]

0 commit comments

Comments
 (0)