Add lang item for AsyncFnKindHelper::Upvars
This commit is contained in:
parent
a9c7e024c0
commit
a03ba7fd2d
5 changed files with 10 additions and 26 deletions
|
@ -228,10 +228,11 @@ language_item_table! {
|
||||||
AsyncFn, sym::async_fn, async_fn_trait, Target::Trait, GenericRequirement::Exact(1);
|
AsyncFn, sym::async_fn, async_fn_trait, Target::Trait, GenericRequirement::Exact(1);
|
||||||
AsyncFnMut, sym::async_fn_mut, async_fn_mut_trait, Target::Trait, GenericRequirement::Exact(1);
|
AsyncFnMut, sym::async_fn_mut, async_fn_mut_trait, Target::Trait, GenericRequirement::Exact(1);
|
||||||
AsyncFnOnce, sym::async_fn_once, async_fn_once_trait, Target::Trait, GenericRequirement::Exact(1);
|
AsyncFnOnce, sym::async_fn_once, async_fn_once_trait, Target::Trait, GenericRequirement::Exact(1);
|
||||||
AsyncFnOnceOutput, sym::async_fn_once_output,async_fn_once_output, Target::AssocTy, GenericRequirement::Exact(1);
|
AsyncFnOnceOutput, sym::async_fn_once_output, async_fn_once_output, Target::AssocTy, GenericRequirement::Exact(1);
|
||||||
CallOnceFuture, sym::call_once_future, call_once_future, Target::AssocTy, GenericRequirement::Exact(1);
|
CallOnceFuture, sym::call_once_future, call_once_future, Target::AssocTy, GenericRequirement::Exact(1);
|
||||||
CallRefFuture, sym::call_ref_future, call_ref_future, Target::AssocTy, GenericRequirement::Exact(2);
|
CallRefFuture, sym::call_ref_future, call_ref_future, Target::AssocTy, GenericRequirement::Exact(2);
|
||||||
AsyncFnKindHelper, sym::async_fn_kind_helper,async_fn_kind_helper, Target::Trait, GenericRequirement::Exact(1);
|
AsyncFnKindHelper, sym::async_fn_kind_helper, async_fn_kind_helper, Target::Trait, GenericRequirement::Exact(1);
|
||||||
|
AsyncFnKindUpvars, sym::async_fn_kind_upvars, async_fn_kind_upvars, Target::AssocTy, GenericRequirement::Exact(5);
|
||||||
|
|
||||||
FnOnceOutput, sym::fn_once_output, fn_once_output, Target::AssocTy, GenericRequirement::None;
|
FnOnceOutput, sym::fn_once_output, fn_once_output, Target::AssocTy, GenericRequirement::None;
|
||||||
|
|
||||||
|
|
|
@ -438,6 +438,7 @@ symbols! {
|
||||||
async_fn,
|
async_fn,
|
||||||
async_fn_in_trait,
|
async_fn_in_trait,
|
||||||
async_fn_kind_helper,
|
async_fn_kind_helper,
|
||||||
|
async_fn_kind_upvars,
|
||||||
async_fn_mut,
|
async_fn_mut,
|
||||||
async_fn_once,
|
async_fn_once,
|
||||||
async_fn_once_output,
|
async_fn_once_output,
|
||||||
|
|
|
@ -9,7 +9,6 @@ use rustc_macros::{TypeFoldable, TypeVisitable};
|
||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
use rustc_middle::traits::solve::Goal;
|
use rustc_middle::traits::solve::Goal;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, Upcast};
|
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, Upcast};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
use crate::solve::EvalCtxt;
|
use crate::solve::EvalCtxt;
|
||||||
|
|
||||||
|
@ -582,13 +581,7 @@ fn coroutine_closure_to_ambiguous_coroutine<'tcx>(
|
||||||
args: ty::CoroutineClosureArgs<'tcx>,
|
args: ty::CoroutineClosureArgs<'tcx>,
|
||||||
sig: ty::CoroutineClosureSignature<'tcx>,
|
sig: ty::CoroutineClosureSignature<'tcx>,
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
let async_fn_kind_trait_def_id = tcx.require_lang_item(LangItem::AsyncFnKindHelper, None);
|
let upvars_projection_def_id = tcx.require_lang_item(LangItem::AsyncFnKindUpvars, None);
|
||||||
let upvars_projection_def_id = tcx
|
|
||||||
.associated_items(async_fn_kind_trait_def_id)
|
|
||||||
.filter_by_name_unhygienic(sym::Upvars)
|
|
||||||
.next()
|
|
||||||
.unwrap()
|
|
||||||
.def_id;
|
|
||||||
let tupled_upvars_ty = Ty::new_projection(
|
let tupled_upvars_ty = Ty::new_projection(
|
||||||
tcx,
|
tcx,
|
||||||
upvars_projection_def_id,
|
upvars_projection_def_id,
|
||||||
|
|
|
@ -1680,14 +1680,8 @@ fn confirm_closure_candidate<'cx, 'tcx>(
|
||||||
args.coroutine_captures_by_ref_ty(),
|
args.coroutine_captures_by_ref_ty(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let async_fn_kind_trait_def_id =
|
let upvars_projection_def_id =
|
||||||
tcx.require_lang_item(LangItem::AsyncFnKindHelper, None);
|
tcx.require_lang_item(LangItem::AsyncFnKindUpvars, None);
|
||||||
let upvars_projection_def_id = tcx
|
|
||||||
.associated_items(async_fn_kind_trait_def_id)
|
|
||||||
.filter_by_name_unhygienic(sym::Upvars)
|
|
||||||
.next()
|
|
||||||
.unwrap()
|
|
||||||
.def_id;
|
|
||||||
let tupled_upvars_ty = Ty::new_projection(
|
let tupled_upvars_ty = Ty::new_projection(
|
||||||
tcx,
|
tcx,
|
||||||
upvars_projection_def_id,
|
upvars_projection_def_id,
|
||||||
|
@ -1816,14 +1810,8 @@ fn confirm_async_closure_candidate<'cx, 'tcx>(
|
||||||
args.coroutine_captures_by_ref_ty(),
|
args.coroutine_captures_by_ref_ty(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let async_fn_kind_trait_def_id =
|
let upvars_projection_def_id =
|
||||||
tcx.require_lang_item(LangItem::AsyncFnKindHelper, None);
|
tcx.require_lang_item(LangItem::AsyncFnKindUpvars, None);
|
||||||
let upvars_projection_def_id = tcx
|
|
||||||
.associated_items(async_fn_kind_trait_def_id)
|
|
||||||
.filter_by_name_unhygienic(sym::Upvars)
|
|
||||||
.next()
|
|
||||||
.unwrap()
|
|
||||||
.def_id;
|
|
||||||
// When we don't know the closure kind (and therefore also the closure's upvars,
|
// When we don't know the closure kind (and therefore also the closure's upvars,
|
||||||
// which are computed at the same time), we must delay the computation of the
|
// which are computed at the same time), we must delay the computation of the
|
||||||
// generator's upvars. We do this using the `AsyncFnKindHelper`, which as a trait
|
// generator's upvars. We do this using the `AsyncFnKindHelper`, which as a trait
|
||||||
|
|
|
@ -146,6 +146,7 @@ mod internal_implementation_detail {
|
||||||
// `for<'env> fn() -> (&'env T, ...)`. This allows us to represent the binder
|
// `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
|
// of the closure's self-capture, and these upvar types will be instantiated with
|
||||||
// the `'closure_env` region provided to the associated type.
|
// 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>;
|
type Upvars<'closure_env, Inputs, Upvars, BorrowedUpvarsAsFnPtr>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue