Skip to content

Commit

Permalink
Rollup merge of rust-lang#125733 - compiler-errors:async-fn-assoc-ite…
Browse files Browse the repository at this point in the history
…m, r=fmease

Add lang items for `AsyncFn*`, `Future`, `AsyncFnKindHelper`'s associated types

Adds lang items for `AsyncFnOnce::Output`, `AsyncFnOnce::CallOnceFuture`, `AsyncFnMut::CallRefFuture`, and uses them in the new solver. I'm mostly interested in doing this to help accelerate uplifting the new trait solver into a separate crate.

The old solver is kind of spaghetti, so I haven't moved that to use these lang items (i.e. it still uses `item_name`-based comparisons).

update: Also adds lang items for `Future::Output` and `AsyncFnKindHelper::Upvars`.

cc ``@lcnr``
  • Loading branch information
fmease authored May 29, 2024
2 parents d82378a + 99eabb4 commit e935223
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use crate::task::{Context, Poll};
pub trait Future {
/// The type of value produced on completion.
#[stable(feature = "futures_api", since = "1.36.0")]
#[rustc_diagnostic_item = "FutureOutput"]
#[cfg_attr(not(bootstrap), lang = "future_output")]
type Output;

/// Attempt to resolve the future to a final value, registering
Expand Down
4 changes: 4 additions & 0 deletions core/src/ops/async_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub trait AsyncFn<Args: Tuple>: AsyncFnMut<Args> {
pub trait AsyncFnMut<Args: Tuple>: AsyncFnOnce<Args> {
/// Future returned by [`AsyncFnMut::async_call_mut`] and [`AsyncFn::async_call`].
#[unstable(feature = "async_fn_traits", issue = "none")]
#[cfg_attr(not(bootstrap), lang = "call_ref_future")]
type CallRefFuture<'a>: Future<Output = Self::Output>
where
Self: 'a;
Expand All @@ -46,10 +47,12 @@ pub trait AsyncFnMut<Args: Tuple>: AsyncFnOnce<Args> {
pub trait AsyncFnOnce<Args: Tuple> {
/// Future returned by [`AsyncFnOnce::async_call_once`].
#[unstable(feature = "async_fn_traits", issue = "none")]
#[cfg_attr(not(bootstrap), lang = "call_once_future")]
type CallOnceFuture: Future<Output = Self::Output>;

/// Output type of the called closure's future.
#[unstable(feature = "async_fn_traits", issue = "none")]
#[cfg_attr(not(bootstrap), lang = "async_fn_once_output")]
type Output;

/// Call the [`AsyncFnOnce`], returning a future which may move out of the called closure.
Expand Down Expand Up @@ -143,6 +146,7 @@ mod internal_implementation_detail {
// `for<'env> fn() -> (&'env T, ...)`. This allows us to represent the binder
// of the closure's self-capture, and these upvar types will be instantiated with
// the `'closure_env` region provided to the associated type.
#[cfg_attr(not(bootstrap), lang = "async_fn_kind_upvars")]
type Upvars<'closure_env, Inputs, Upvars, BorrowedUpvarsAsFnPtr>;
}
}

0 comments on commit e935223

Please sign in to comment.