Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 36fe959

Browse files
authored
Unrolled build for rust-lang#132612
Rollup merge of rust-lang#132612 - compiler-errors:async-trait-bounds, r=lcnr Gate async fn trait bound modifier on `async_trait_bounds` This PR moves `async Fn()` trait bounds into a new feature gate: `feature(async_trait_bounds)`. The general vibe is that we will most likely stabilize the `feature(async_closure)` *without* the `async Fn()` trait bound modifier, so we need to gate that separately. We're trying to work on the general vision of `async` trait bound modifier general in: rust-lang/rfcs#3710, however that RFC still needs more time for consensus to converge, and we've decided that the value that users get from calling the bound `async Fn()` is *not really* worth blocking landing async closures in general.
2 parents 490b2cc + 59e3e89 commit 36fe959

File tree

64 files changed

+147
-106
lines changed

Some content is hidden

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

64 files changed

+147
-106
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,11 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
516516
"async closures are unstable",
517517
"to use an async block, remove the `||`: `async {`"
518518
);
519+
gate_all!(
520+
async_trait_bounds,
521+
"`async` trait bounds are unstable",
522+
"use the desugared name of the async trait, such as `AsyncFn`"
523+
);
519524
gate_all!(async_for_loop, "`for await` loops are experimental");
520525
gate_all!(
521526
closure_lifetime_binder,

compiler/rustc_feature/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ declare_features! (
394394
(unstable, async_fn_track_caller, "1.73.0", Some(110011)),
395395
/// Allows `for await` loops.
396396
(unstable, async_for_loop, "1.77.0", Some(118898)),
397+
/// Allows `async` trait bound modifier.
398+
(unstable, async_trait_bounds, "CURRENT_RUSTC_VERSION", Some(62290)),
397399
/// Allows using C-variadics.
398400
(unstable, c_variadic, "1.34.0", Some(44930)),
399401
/// Allows the use of `#[cfg(<true/false>)]`.

compiler/rustc_parse/src/parser/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ impl<'a> Parser<'a> {
940940
let asyncness = if self.token.uninterpolated_span().at_least_rust_2018()
941941
&& self.eat_keyword(kw::Async)
942942
{
943-
self.psess.gated_spans.gate(sym::async_closure, self.prev_token.span);
943+
self.psess.gated_spans.gate(sym::async_trait_bounds, self.prev_token.span);
944944
BoundAsyncness::Async(self.prev_token.span)
945945
} else if self.may_recover()
946946
&& self.token.uninterpolated_span().is_rust_2015()
@@ -951,7 +951,7 @@ impl<'a> Parser<'a> {
951951
span: self.prev_token.span,
952952
help: HelpUseLatestEdition::new(),
953953
});
954-
self.psess.gated_spans.gate(sym::async_closure, self.prev_token.span);
954+
self.psess.gated_spans.gate(sym::async_trait_bounds, self.prev_token.span);
955955
BoundAsyncness::Async(self.prev_token.span)
956956
} else {
957957
BoundAsyncness::Normal

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ symbols! {
468468
async_for_loop,
469469
async_iterator,
470470
async_iterator_poll_next,
471+
async_trait_bounds,
471472
atomic,
472473
atomic_mod,
473474
atomics,

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
794794
closure_def_id,
795795
found_kind,
796796
expected_kind,
797-
"async ",
797+
"Async",
798798
);
799799
self.note_obligation_cause(&mut err, &obligation);
800800
self.point_at_returns_when_relevant(&mut err, &obligation);

src/tools/miri/tests/pass/async-closure-captures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Same as rustc's `tests/ui/async-await/async-closures/captures.rs`, keep in sync
22

3-
#![feature(async_closure, noop_waker)]
3+
#![feature(async_closure, noop_waker, async_trait_bounds)]
44

55
use std::future::Future;
66
use std::pin::pin;

src/tools/miri/tests/pass/async-closure-drop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(async_closure, noop_waker, async_fn_traits)]
1+
#![feature(async_closure, noop_waker, async_trait_bounds)]
22

33
use std::future::Future;
44
use std::pin::pin;

tests/codegen/async-closure-debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#![feature(async_closure)]
1111

12-
fn async_closure_test(upvar: &str) -> impl async Fn() + '_ {
12+
fn async_closure_test(upvar: &str) -> impl AsyncFn() + '_ {
1313
async move || {
1414
let hello = String::from("hello");
1515
println!("{hello}, {upvar}");

tests/coverage/async_closure.cov-map

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
Function name: async_closure::call_once::<async_closure::main::{closure#0}>
2-
Raw bytes (9): 0x[01, 01, 00, 01, 01, 07, 01, 00, 2c]
2+
Raw bytes (9): 0x[01, 01, 00, 01, 01, 07, 01, 00, 2b]
33
Number of files: 1
44
- file 0 => global file 1
55
Number of expressions: 0
66
Number of file 0 mappings: 1
7-
- Code(Counter(0)) at (prev + 7, 1) to (start + 0, 44)
7+
- Code(Counter(0)) at (prev + 7, 1) to (start + 0, 43)
88
Highest counter ID seen: c0
99

1010
Function name: async_closure::call_once::<async_closure::main::{closure#0}>::{closure#0}
11-
Raw bytes (14): 0x[01, 01, 00, 02, 01, 07, 2c, 01, 0e, 05, 02, 01, 00, 02]
11+
Raw bytes (14): 0x[01, 01, 00, 02, 01, 07, 2b, 01, 0e, 05, 02, 01, 00, 02]
1212
Number of files: 1
1313
- file 0 => global file 1
1414
Number of expressions: 0
1515
Number of file 0 mappings: 2
16-
- Code(Counter(0)) at (prev + 7, 44) to (start + 1, 14)
16+
- Code(Counter(0)) at (prev + 7, 43) to (start + 1, 14)
1717
- Code(Counter(1)) at (prev + 2, 1) to (start + 0, 2)
1818
Highest counter ID seen: c1
1919

tests/coverage/async_closure.coverage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
LL| |//@ aux-build: executor.rs
55
LL| |extern crate executor;
66
LL| |
7-
LL| 1|async fn call_once(f: impl async FnOnce()) {
7+
LL| 1|async fn call_once(f: impl AsyncFnOnce()) {
88
LL| 1| f().await;
99
LL| 1|}
1010
LL| |

0 commit comments

Comments
 (0)