s/Generator/Coroutine/
This commit is contained in:
parent
96027d945b
commit
60956837cf
310 changed files with 1271 additions and 1271 deletions
|
@ -200,7 +200,7 @@ pub(super) trait GoalKind<'tcx>:
|
|||
) -> QueryResult<'tcx>;
|
||||
|
||||
/// A generator (that doesn't come from an `async` desugaring) is known to
|
||||
/// implement `Generator<R, Yield = Y, Return = O>`, given the resume, yield,
|
||||
/// implement `Coroutine<R, Yield = Y, Return = O>`, given the resume, yield,
|
||||
/// and return types of the generator computed during type-checking.
|
||||
fn consider_builtin_generator_candidate(
|
||||
ecx: &mut EvalCtxt<'_, 'tcx>,
|
||||
|
@ -410,7 +410,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
| ty::FnPtr(_)
|
||||
| ty::Dynamic(_, _, _)
|
||||
| ty::Closure(_, _)
|
||||
| ty::Generator(_, _, _)
|
||||
| ty::Coroutine(_, _, _)
|
||||
| ty::Never
|
||||
| ty::Tuple(_) => {
|
||||
let simp =
|
||||
|
@ -469,7 +469,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
// FIXME: These should ideally not exist as a self type. It would be nice for
|
||||
// the builtin auto trait impls of generators to instead directly recurse
|
||||
// into the witness.
|
||||
ty::GeneratorWitness(..) => (),
|
||||
ty::CoroutineWitness(..) => (),
|
||||
|
||||
// These variants should not exist as a self type.
|
||||
ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_))
|
||||
|
@ -620,8 +620,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
| ty::FnPtr(_)
|
||||
| ty::Dynamic(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(..)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Param(_)
|
||||
|
@ -776,8 +776,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
| ty::FnPtr(_)
|
||||
| ty::Alias(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(..)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Param(_)
|
||||
|
|
|
@ -56,12 +56,12 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_auto_trait<'tcx>(
|
|||
|
||||
ty::Closure(_, ref args) => Ok(vec![args.as_closure().tupled_upvars_ty()]),
|
||||
|
||||
ty::Generator(_, ref args, _) => {
|
||||
ty::Coroutine(_, ref args, _) => {
|
||||
let generator_args = args.as_generator();
|
||||
Ok(vec![generator_args.tupled_upvars_ty(), generator_args.witness()])
|
||||
}
|
||||
|
||||
ty::GeneratorWitness(def_id, args) => Ok(ecx
|
||||
ty::CoroutineWitness(def_id, args) => Ok(ecx
|
||||
.tcx()
|
||||
.generator_hidden_types(def_id)
|
||||
.map(|bty| {
|
||||
|
@ -122,8 +122,8 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<'tcx>(
|
|||
| ty::RawPtr(..)
|
||||
| ty::Char
|
||||
| ty::Ref(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(..)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Array(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Never
|
||||
|
@ -174,7 +174,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
|
|||
ty::Dynamic(..)
|
||||
| ty::Str
|
||||
| ty::Slice(_)
|
||||
| ty::Generator(_, _, Movability::Static)
|
||||
| ty::Coroutine(_, _, Movability::Static)
|
||||
| ty::Foreign(..)
|
||||
| ty::Ref(_, _, Mutability::Mut)
|
||||
| ty::Adt(_, _)
|
||||
|
@ -191,7 +191,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
|
|||
|
||||
ty::Closure(_, args) => Ok(vec![args.as_closure().tupled_upvars_ty()]),
|
||||
|
||||
ty::Generator(_, args, Movability::Movable) => {
|
||||
ty::Coroutine(_, args, Movability::Movable) => {
|
||||
if ecx.tcx().features().generator_clone {
|
||||
let generator = args.as_generator();
|
||||
Ok(vec![generator.tupled_upvars_ty(), generator.witness()])
|
||||
|
@ -200,7 +200,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
|
|||
}
|
||||
}
|
||||
|
||||
ty::GeneratorWitness(def_id, args) => Ok(ecx
|
||||
ty::CoroutineWitness(def_id, args) => Ok(ecx
|
||||
.tcx()
|
||||
.generator_hidden_types(def_id)
|
||||
.map(|bty| {
|
||||
|
@ -275,8 +275,8 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<'tcx>(
|
|||
| ty::RawPtr(_)
|
||||
| ty::Ref(_, _, _)
|
||||
| ty::Dynamic(_, _, _)
|
||||
| ty::Generator(_, _, _)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(_, _, _)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Alias(_, _)
|
||||
|
|
|
@ -329,8 +329,8 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
|
|||
| ty::FnPtr(_)
|
||||
| ty::Dynamic(_, _, _)
|
||||
| ty::Closure(_, _)
|
||||
| ty::Generator(_, _, _)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(_, _, _)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Alias(_, _)
|
||||
|
|
|
@ -392,8 +392,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
|
|||
| ty::FnPtr(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Infer(ty::IntVar(..) | ty::FloatVar(..))
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(..)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
| ty::Foreign(..) => tcx.types.unit,
|
||||
|
||||
|
@ -459,11 +459,11 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
|
|||
goal: Goal<'tcx, Self>,
|
||||
) -> QueryResult<'tcx> {
|
||||
let self_ty = goal.predicate.self_ty();
|
||||
let ty::Generator(def_id, args, _) = *self_ty.kind() else {
|
||||
let ty::Coroutine(def_id, args, _) = *self_ty.kind() else {
|
||||
return Err(NoSolution);
|
||||
};
|
||||
|
||||
// Generators are not futures unless they come from `async` desugaring
|
||||
// Coroutines are not futures unless they come from `async` desugaring
|
||||
let tcx = ecx.tcx();
|
||||
if !tcx.generator_is_async(def_id) {
|
||||
return Err(NoSolution);
|
||||
|
@ -490,7 +490,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
|
|||
goal: Goal<'tcx, Self>,
|
||||
) -> QueryResult<'tcx> {
|
||||
let self_ty = goal.predicate.self_ty();
|
||||
let ty::Generator(def_id, args, _) = *self_ty.kind() else {
|
||||
let ty::Coroutine(def_id, args, _) = *self_ty.kind() else {
|
||||
return Err(NoSolution);
|
||||
};
|
||||
|
||||
|
@ -508,7 +508,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
|
|||
} else if name == sym::Yield {
|
||||
generator.yield_ty().into()
|
||||
} else {
|
||||
bug!("unexpected associated item `<{self_ty} as Generator>::{name}`")
|
||||
bug!("unexpected associated item `<{self_ty} as Coroutine>::{name}`")
|
||||
};
|
||||
|
||||
Self::consider_implied_clause(
|
||||
|
@ -561,8 +561,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
|
|||
| ty::FnPtr(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Infer(ty::IntVar(..) | ty::FloatVar(..))
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(..)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
| ty::Foreign(..)
|
||||
| ty::Adt(_, _)
|
||||
|
|
|
@ -319,11 +319,11 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
|
|||
return Err(NoSolution);
|
||||
}
|
||||
|
||||
let ty::Generator(def_id, _, _) = *goal.predicate.self_ty().kind() else {
|
||||
let ty::Coroutine(def_id, _, _) = *goal.predicate.self_ty().kind() else {
|
||||
return Err(NoSolution);
|
||||
};
|
||||
|
||||
// Generators are not futures unless they come from `async` desugaring
|
||||
// Coroutines are not futures unless they come from `async` desugaring
|
||||
let tcx = ecx.tcx();
|
||||
if !tcx.generator_is_async(def_id) {
|
||||
return Err(NoSolution);
|
||||
|
@ -344,7 +344,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
|
|||
}
|
||||
|
||||
let self_ty = goal.predicate.self_ty();
|
||||
let ty::Generator(def_id, args, _) = *self_ty.kind() else {
|
||||
let ty::Coroutine(def_id, args, _) = *self_ty.kind() else {
|
||||
return Err(NoSolution);
|
||||
};
|
||||
|
||||
|
@ -844,10 +844,10 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
|
||||
ty::Infer(_) | ty::Bound(_, _) => bug!("unexpected type `{self_ty}`"),
|
||||
|
||||
// Generators have one special built-in candidate, `Unpin`, which
|
||||
// Coroutines have one special built-in candidate, `Unpin`, which
|
||||
// takes precedence over the structural auto trait candidate being
|
||||
// assembled.
|
||||
ty::Generator(_, _, movability)
|
||||
ty::Coroutine(_, _, movability)
|
||||
if Some(goal.predicate.def_id()) == self.tcx().lang_items().unpin_trait() =>
|
||||
{
|
||||
match movability {
|
||||
|
@ -879,8 +879,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
| ty::FnDef(_, _)
|
||||
| ty::FnPtr(_)
|
||||
| ty::Closure(_, _)
|
||||
| ty::Generator(_, _, _)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(_, _, _)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Adt(_, _)
|
||||
|
|
|
@ -817,7 +817,7 @@ where
|
|||
}
|
||||
}
|
||||
ty::Error(_) => ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty)),
|
||||
ty::Closure(did, ..) | ty::Generator(did, ..) => {
|
||||
ty::Closure(did, ..) | ty::Coroutine(did, ..) => {
|
||||
if self.def_id_is_local(did) {
|
||||
ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty))
|
||||
} else {
|
||||
|
@ -827,7 +827,7 @@ where
|
|||
// This should only be created when checking whether we have to check whether some
|
||||
// auto trait impl applies. There will never be multiple impls, so we can just
|
||||
// act as if it were a local type here.
|
||||
ty::GeneratorWitness(..) => ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty)),
|
||||
ty::CoroutineWitness(..) => ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty)),
|
||||
ty::Alias(ty::Opaque, ..) => {
|
||||
// This merits some explanation.
|
||||
// Normally, opaque types are not involved when performing
|
||||
|
|
|
@ -22,7 +22,7 @@ use rustc_hir::def_id::DefId;
|
|||
use rustc_hir::intravisit::Visitor;
|
||||
use rustc_hir::is_range_literal;
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_hir::{AsyncGeneratorKind, GeneratorKind, Node};
|
||||
use rustc_hir::{AsyncCoroutineKind, CoroutineKind, Node};
|
||||
use rustc_hir::{Expr, HirId};
|
||||
use rustc_infer::infer::error_reporting::TypeErrCtxt;
|
||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
|
@ -47,7 +47,7 @@ use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
|
|||
use rustc_middle::ty::print::{with_forced_trimmed_paths, with_no_trimmed_paths};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum GeneratorInteriorOrUpvar {
|
||||
pub enum CoroutineInteriorOrUpvar {
|
||||
// span of interior type
|
||||
Interior(Span, Option<(Span, Option<Span>)>),
|
||||
// span of upvar
|
||||
|
@ -57,9 +57,9 @@ pub enum GeneratorInteriorOrUpvar {
|
|||
// This type provides a uniform interface to retrieve data on generators, whether it originated from
|
||||
// the local crate being compiled or from a foreign crate.
|
||||
#[derive(Debug)]
|
||||
struct GeneratorData<'tcx, 'a>(&'a TypeckResults<'tcx>);
|
||||
struct CoroutineData<'tcx, 'a>(&'a TypeckResults<'tcx>);
|
||||
|
||||
impl<'tcx, 'a> GeneratorData<'tcx, 'a> {
|
||||
impl<'tcx, 'a> CoroutineData<'tcx, 'a> {
|
||||
/// Try to get information about variables captured by the generator that matches a type we are
|
||||
/// looking for with `ty_matches` function. We uses it to find upvar which causes a failure to
|
||||
/// meet an obligation
|
||||
|
@ -68,7 +68,7 @@ impl<'tcx, 'a> GeneratorData<'tcx, 'a> {
|
|||
infer_context: &InferCtxt<'tcx>,
|
||||
generator_did: DefId,
|
||||
ty_matches: F,
|
||||
) -> Option<GeneratorInteriorOrUpvar>
|
||||
) -> Option<CoroutineInteriorOrUpvar>
|
||||
where
|
||||
F: Fn(ty::Binder<'tcx, Ty<'tcx>>) -> bool,
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ impl<'tcx, 'a> GeneratorData<'tcx, 'a> {
|
|||
let upvar_ty = self.0.node_type(*upvar_id);
|
||||
let upvar_ty = infer_context.resolve_vars_if_possible(upvar_ty);
|
||||
ty_matches(ty::Binder::dummy(upvar_ty))
|
||||
.then(|| GeneratorInteriorOrUpvar::Upvar(upvar.span))
|
||||
.then(|| CoroutineInteriorOrUpvar::Upvar(upvar.span))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ pub trait TypeErrCtxtExt<'tcx> {
|
|||
fn note_obligation_cause_for_async_await(
|
||||
&self,
|
||||
err: &mut Diagnostic,
|
||||
interior_or_upvar_span: GeneratorInteriorOrUpvar,
|
||||
interior_or_upvar_span: CoroutineInteriorOrUpvar,
|
||||
is_async: bool,
|
||||
outer_generator: Option<DefId>,
|
||||
trait_pred: ty::TraitPredicate<'tcx>,
|
||||
|
@ -1982,7 +1982,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
let argument_kind = match expected.skip_binder().self_ty().kind() {
|
||||
ty::Closure(..) => "closure",
|
||||
ty::Generator(..) => "generator",
|
||||
ty::Coroutine(..) => "generator",
|
||||
_ => "function",
|
||||
};
|
||||
let mut err = struct_span_err!(
|
||||
|
@ -2190,7 +2190,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
);
|
||||
|
||||
match *ty.kind() {
|
||||
ty::Generator(did, ..) | ty::GeneratorWitness(did, _) => {
|
||||
ty::Coroutine(did, ..) | ty::CoroutineWitness(did, _) => {
|
||||
generator = generator.or(Some(did));
|
||||
outer_generator = Some(did);
|
||||
}
|
||||
|
@ -2219,7 +2219,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
);
|
||||
|
||||
match *ty.kind() {
|
||||
ty::Generator(did, ..) | ty::GeneratorWitness(did, ..) => {
|
||||
ty::Coroutine(did, ..) | ty::CoroutineWitness(did, ..) => {
|
||||
generator = generator.or(Some(did));
|
||||
outer_generator = Some(did);
|
||||
}
|
||||
|
@ -2299,9 +2299,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
// cycles. If we can't use resolved types because the generator comes from another crate,
|
||||
// we still provide a targeted error but without all the relevant spans.
|
||||
let generator_data = match &self.typeck_results {
|
||||
Some(t) if t.hir_owner.to_def_id() == generator_did_root => GeneratorData(&t),
|
||||
Some(t) if t.hir_owner.to_def_id() == generator_did_root => CoroutineData(&t),
|
||||
_ if generator_did.is_local() => {
|
||||
GeneratorData(self.tcx.typeck(generator_did.expect_local()))
|
||||
CoroutineData(self.tcx.typeck(generator_did.expect_local()))
|
||||
}
|
||||
_ => return false,
|
||||
};
|
||||
|
@ -2331,7 +2331,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
let decl = &generator_info.field_tys[local];
|
||||
debug!(?decl);
|
||||
if ty_matches(ty::Binder::dummy(decl.ty)) && !decl.ignore_for_traits {
|
||||
interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior(
|
||||
interior_or_upvar_span = Some(CoroutineInteriorOrUpvar::Interior(
|
||||
decl.source_info.span,
|
||||
Some((source_info.span, from_awaited_ty)),
|
||||
));
|
||||
|
@ -2347,7 +2347,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
|
||||
if interior_or_upvar_span.is_none() && !generator_did.is_local() {
|
||||
interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior(span, None));
|
||||
interior_or_upvar_span = Some(CoroutineInteriorOrUpvar::Interior(span, None));
|
||||
}
|
||||
|
||||
debug!(?interior_or_upvar_span);
|
||||
|
@ -2375,7 +2375,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
fn note_obligation_cause_for_async_await(
|
||||
&self,
|
||||
err: &mut Diagnostic,
|
||||
interior_or_upvar_span: GeneratorInteriorOrUpvar,
|
||||
interior_or_upvar_span: CoroutineInteriorOrUpvar,
|
||||
is_async: bool,
|
||||
outer_generator: Option<DefId>,
|
||||
trait_pred: ty::TraitPredicate<'tcx>,
|
||||
|
@ -2409,8 +2409,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
let message = outer_generator
|
||||
.and_then(|generator_did| {
|
||||
Some(match self.tcx.generator_kind(generator_did).unwrap() {
|
||||
GeneratorKind::Gen => format!("generator is not {trait_name}"),
|
||||
GeneratorKind::Async(AsyncGeneratorKind::Fn) => self
|
||||
CoroutineKind::Gen => format!("generator is not {trait_name}"),
|
||||
CoroutineKind::Async(AsyncCoroutineKind::Fn) => self
|
||||
.tcx
|
||||
.parent(generator_did)
|
||||
.as_local()
|
||||
|
@ -2419,10 +2419,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
.map(|name| {
|
||||
format!("future returned by `{name}` is not {trait_name}")
|
||||
})?,
|
||||
GeneratorKind::Async(AsyncGeneratorKind::Block) => {
|
||||
CoroutineKind::Async(AsyncCoroutineKind::Block) => {
|
||||
format!("future created by async block is not {trait_name}")
|
||||
}
|
||||
GeneratorKind::Async(AsyncGeneratorKind::Closure) => {
|
||||
CoroutineKind::Async(AsyncCoroutineKind::Closure) => {
|
||||
format!("future created by async closure is not {trait_name}")
|
||||
}
|
||||
})
|
||||
|
@ -2475,7 +2475,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
);
|
||||
};
|
||||
match interior_or_upvar_span {
|
||||
GeneratorInteriorOrUpvar::Interior(interior_span, interior_extra_info) => {
|
||||
CoroutineInteriorOrUpvar::Interior(interior_span, interior_extra_info) => {
|
||||
if let Some((yield_span, from_awaited_ty)) = interior_extra_info {
|
||||
if let Some(await_span) = from_awaited_ty {
|
||||
// The type causing this obligation is one being awaited at await_span.
|
||||
|
@ -2498,7 +2498,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
GeneratorInteriorOrUpvar::Upvar(upvar_span) => {
|
||||
CoroutineInteriorOrUpvar::Upvar(upvar_span) => {
|
||||
// `Some((ref_ty, is_mut))` if `target_ty` is `&T` or `&mut T` and fails to impl `Send`
|
||||
let non_send = match target_ty.kind() {
|
||||
ty::Ref(_, ref_ty, mutability) => match self.evaluate_obligation(&obligation) {
|
||||
|
@ -2880,10 +2880,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
err.span_label(span, "this closure captures all values by move");
|
||||
}
|
||||
}
|
||||
ObligationCauseCode::SizedGeneratorInterior(generator_def_id) => {
|
||||
ObligationCauseCode::SizedCoroutineInterior(generator_def_id) => {
|
||||
let what = match self.tcx.generator_kind(generator_def_id) {
|
||||
None | Some(hir::GeneratorKind::Gen) => "yield",
|
||||
Some(hir::GeneratorKind::Async(..)) => "await",
|
||||
None | Some(hir::CoroutineKind::Gen) => "yield",
|
||||
Some(hir::CoroutineKind::Async(..)) => "await",
|
||||
};
|
||||
err.note(format!(
|
||||
"all values live across `{what}` must have a statically known size"
|
||||
|
@ -2905,7 +2905,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
return;
|
||||
}
|
||||
|
||||
// If the obligation for a tuple is set directly by a Generator or Closure,
|
||||
// If the obligation for a tuple is set directly by a Coroutine or Closure,
|
||||
// then the tuple must be the one containing capture types.
|
||||
let is_upvar_tys_infer_tuple = if !matches!(ty.kind(), ty::Tuple(..)) {
|
||||
false
|
||||
|
@ -2915,7 +2915,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
let parent_trait_ref =
|
||||
self.resolve_vars_if_possible(data.parent_trait_pred);
|
||||
let nested_ty = parent_trait_ref.skip_binder().self_ty();
|
||||
matches!(nested_ty.kind(), ty::Generator(..))
|
||||
matches!(nested_ty.kind(), ty::Coroutine(..))
|
||||
|| matches!(nested_ty.kind(), ty::Closure(..))
|
||||
} else {
|
||||
false
|
||||
|
@ -2935,7 +2935,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
},
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => {
|
||||
// If the previous type is async fn, this is the future generated by the body of an async function.
|
||||
// Avoid printing it twice (it was already printed in the `ty::Generator` arm below).
|
||||
// Avoid printing it twice (it was already printed in the `ty::Coroutine` arm below).
|
||||
let is_future = tcx.ty_is_opaque_future(ty);
|
||||
debug!(
|
||||
?obligated_types,
|
||||
|
@ -2944,7 +2944,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
);
|
||||
if is_future
|
||||
&& obligated_types.last().is_some_and(|ty| match ty.kind() {
|
||||
ty::Generator(last_def_id, ..) => {
|
||||
ty::Coroutine(last_def_id, ..) => {
|
||||
tcx.generator_is_async(*last_def_id)
|
||||
}
|
||||
_ => false,
|
||||
|
@ -2954,7 +2954,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
err.span_note(self.tcx.def_span(def_id), msg)
|
||||
}
|
||||
ty::GeneratorWitness(def_id, args) => {
|
||||
ty::CoroutineWitness(def_id, args) => {
|
||||
use std::fmt::Write;
|
||||
|
||||
// FIXME: this is kind of an unusual format for rustc, can we make it more clear?
|
||||
|
@ -2968,7 +2968,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
err.note(msg.trim_end_matches(", ").to_string())
|
||||
}
|
||||
ty::Generator(def_id, _, _) => {
|
||||
ty::Coroutine(def_id, _, _) => {
|
||||
let sp = self.tcx.def_span(def_id);
|
||||
|
||||
// Special-case this to say "async block" instead of `[static generator]`.
|
||||
|
@ -3271,7 +3271,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
) {
|
||||
if let Some(body_id) = self.tcx.hir().maybe_body_owned_by(obligation.cause.body_id) {
|
||||
let body = self.tcx.hir().body(body_id);
|
||||
if let Some(hir::GeneratorKind::Async(_)) = body.generator_kind {
|
||||
if let Some(hir::CoroutineKind::Async(_)) = body.generator_kind {
|
||||
let future_trait = self.tcx.require_lang_item(LangItem::Future, None);
|
||||
|
||||
let self_ty = self.resolve_vars_if_possible(trait_pred.self_ty());
|
||||
|
|
|
@ -1564,9 +1564,9 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
ty::Alias(ty::Weak, ..) => Some(15),
|
||||
ty::Never => Some(16),
|
||||
ty::Adt(..) => Some(17),
|
||||
ty::Generator(..) => Some(18),
|
||||
ty::Coroutine(..) => Some(18),
|
||||
ty::Foreign(..) => Some(19),
|
||||
ty::GeneratorWitness(..) => Some(20),
|
||||
ty::CoroutineWitness(..) => Some(20),
|
||||
ty::Placeholder(..) | ty::Bound(..) | ty::Infer(..) | ty::Error(_) => None,
|
||||
}
|
||||
}
|
||||
|
@ -1615,10 +1615,10 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
fn describe_generator(&self, body_id: hir::BodyId) -> Option<&'static str> {
|
||||
self.tcx.hir().body(body_id).generator_kind.map(|gen_kind| match gen_kind {
|
||||
hir::GeneratorKind::Gen => "a generator",
|
||||
hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) => "an async block",
|
||||
hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Fn) => "an async function",
|
||||
hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Closure) => "an async closure",
|
||||
hir::CoroutineKind::Gen => "a generator",
|
||||
hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Block) => "an async block",
|
||||
hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Fn) => "an async function",
|
||||
hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Closure) => "an async closure",
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -3098,7 +3098,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
};
|
||||
|
||||
let found_did = match *found_trait_ty.kind() {
|
||||
ty::Closure(did, _) | ty::Foreign(did) | ty::FnDef(did, _) | ty::Generator(did, ..) => {
|
||||
ty::Closure(did, _) | ty::Foreign(did) | ty::FnDef(did, _) | ty::Coroutine(did, ..) => {
|
||||
Some(did)
|
||||
}
|
||||
ty::Adt(def, _) => Some(def.did()),
|
||||
|
|
|
@ -1811,8 +1811,8 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
|||
| ty::FnPtr(..)
|
||||
| ty::Dynamic(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(..)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(..)
|
||||
// Integers and floats always have `u8` as their discriminant.
|
||||
|
@ -1860,8 +1860,8 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
|||
| ty::FnPtr(..)
|
||||
| ty::Dynamic(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(..)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
// Extern types have unit metadata, according to RFC 2850
|
||||
| ty::Foreign(_)
|
||||
|
@ -2035,7 +2035,7 @@ fn confirm_generator_candidate<'cx, 'tcx>(
|
|||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
nested: Vec<PredicateObligation<'tcx>>,
|
||||
) -> Progress<'tcx> {
|
||||
let ty::Generator(_, args, _) =
|
||||
let ty::Coroutine(_, args, _) =
|
||||
selcx.infcx.shallow_resolve(obligation.predicate.self_ty()).kind()
|
||||
else {
|
||||
unreachable!()
|
||||
|
@ -2053,7 +2053,7 @@ fn confirm_generator_candidate<'cx, 'tcx>(
|
|||
|
||||
let tcx = selcx.tcx();
|
||||
|
||||
let gen_def_id = tcx.require_lang_item(LangItem::Generator, None);
|
||||
let gen_def_id = tcx.require_lang_item(LangItem::Coroutine, None);
|
||||
|
||||
let predicate = super::util::generator_trait_ref_and_outputs(
|
||||
tcx,
|
||||
|
@ -2087,7 +2087,7 @@ fn confirm_future_candidate<'cx, 'tcx>(
|
|||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
nested: Vec<PredicateObligation<'tcx>>,
|
||||
) -> Progress<'tcx> {
|
||||
let ty::Generator(_, args, _) =
|
||||
let ty::Coroutine(_, args, _) =
|
||||
selcx.infcx.shallow_resolve(obligation.predicate.self_ty()).kind()
|
||||
else {
|
||||
unreachable!()
|
||||
|
|
|
@ -35,7 +35,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
|||
| ty::FnDef(..)
|
||||
| ty::FnPtr(_)
|
||||
| ty::Char
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::RawPtr(_)
|
||||
| ty::Ref(..)
|
||||
| ty::Str
|
||||
|
@ -72,7 +72,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
|||
| ty::Placeholder(..)
|
||||
| ty::Infer(_)
|
||||
| ty::Bound(..)
|
||||
| ty::Generator(..) => false,
|
||||
| ty::Coroutine(..) => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
|
|||
| ty::Ref(..)
|
||||
| ty::FnDef(..)
|
||||
| ty::FnPtr(_)
|
||||
| ty::GeneratorWitness(..) => {
|
||||
| ty::CoroutineWitness(..) => {
|
||||
// these types never have a destructor
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
|
|||
})?
|
||||
}
|
||||
|
||||
ty::Generator(_, args, _movability) => {
|
||||
ty::Coroutine(_, args, _movability) => {
|
||||
// rust-lang/rust#49918: types can be constructed, stored
|
||||
// in the interior, and sit idle when generator yields
|
||||
// (and is subsequently dropped).
|
||||
|
@ -266,7 +266,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
|
|||
// its interior).
|
||||
//
|
||||
// However, the interior's representation uses things like
|
||||
// GeneratorWitness that explicitly assume they are not
|
||||
// CoroutineWitness that explicitly assume they are not
|
||||
// traversed in such a manner. So instead, we will
|
||||
// simplify things for now by treating all generators as
|
||||
// if they were like trait objects, where its upvars must
|
||||
|
|
|
@ -212,11 +212,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let self_ty = obligation.self_ty().skip_binder();
|
||||
match self_ty.kind() {
|
||||
// async constructs get lowered to a special kind of generator that
|
||||
// should *not* `impl Generator`.
|
||||
ty::Generator(did, ..) if !self.tcx().generator_is_async(*did) => {
|
||||
// should *not* `impl Coroutine`.
|
||||
ty::Coroutine(did, ..) if !self.tcx().generator_is_async(*did) => {
|
||||
debug!(?self_ty, ?obligation, "assemble_generator_candidates",);
|
||||
|
||||
candidates.vec.push(GeneratorCandidate);
|
||||
candidates.vec.push(CoroutineCandidate);
|
||||
}
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
debug!("assemble_generator_candidates: ambiguous self-type");
|
||||
|
@ -232,7 +232,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
candidates: &mut SelectionCandidateSet<'tcx>,
|
||||
) {
|
||||
let self_ty = obligation.self_ty().skip_binder();
|
||||
if let ty::Generator(did, ..) = self_ty.kind() {
|
||||
if let ty::Coroutine(did, ..) = self_ty.kind() {
|
||||
// async constructs get lowered to a special kind of generator that
|
||||
// should directly `impl Future`.
|
||||
if self.tcx().generator_is_async(*did) {
|
||||
|
@ -435,8 +435,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
| ty::RawPtr(_)
|
||||
| ty::Ref(_, _, _)
|
||||
| ty::Closure(_, _)
|
||||
| ty::Generator(_, _, _)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(_, _, _)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Error(_) => return true,
|
||||
|
@ -513,7 +513,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// The auto impl might apply; we don't know.
|
||||
candidates.ambiguous = true;
|
||||
}
|
||||
ty::Generator(_, _, movability)
|
||||
ty::Coroutine(_, _, movability)
|
||||
if self.tcx().lang_items().unpin_trait() == Some(def_id) =>
|
||||
{
|
||||
match movability {
|
||||
|
@ -570,10 +570,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
| ty::FnDef(..)
|
||||
| ty::FnPtr(_)
|
||||
| ty::Closure(_, _)
|
||||
| ty::Generator(..)
|
||||
| ty::Coroutine(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::GeneratorWitness(..) => {
|
||||
| ty::CoroutineWitness(..) => {
|
||||
// Only consider auto impls if there are no manual impls for the root of `self_ty`.
|
||||
//
|
||||
// For example, we only consider auto candidates for `&i32: Auto` if no explicit impl
|
||||
|
@ -947,9 +947,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
| ty::Array(..)
|
||||
| ty::Slice(_)
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::Coroutine(..)
|
||||
| ty::Tuple(_)
|
||||
| ty::GeneratorWitness(..) => {
|
||||
| ty::CoroutineWitness(..) => {
|
||||
// These are built-in, and cannot have a custom `impl const Destruct`.
|
||||
candidates.vec.push(ConstDestructCandidate(None));
|
||||
}
|
||||
|
@ -1021,8 +1021,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
| ty::FnPtr(_)
|
||||
| ty::Dynamic(_, _, _)
|
||||
| ty::Closure(_, _)
|
||||
| ty::Generator(_, _, _)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(_, _, _)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
| ty::Alias(..)
|
||||
| ty::Param(_)
|
||||
|
@ -1082,8 +1082,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
| ty::Placeholder(..)
|
||||
| ty::Dynamic(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(..)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(..)
|
||||
| ty::Alias(..)
|
||||
|
|
|
@ -83,7 +83,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
ImplSource::Builtin(BuiltinImplSource::Misc, vtable_closure)
|
||||
}
|
||||
|
||||
GeneratorCandidate => {
|
||||
CoroutineCandidate => {
|
||||
let vtable_generator = self.confirm_generator_candidate(obligation)?;
|
||||
ImplSource::Builtin(BuiltinImplSource::Misc, vtable_generator)
|
||||
}
|
||||
|
@ -719,7 +719,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// touch bound regions, they just capture the in-scope
|
||||
// type/region parameters.
|
||||
let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder());
|
||||
let ty::Generator(generator_def_id, args, _) = *self_ty.kind() else {
|
||||
let ty::Coroutine(generator_def_id, args, _) = *self_ty.kind() else {
|
||||
bug!("closure candidate for non-closure {:?}", obligation);
|
||||
};
|
||||
|
||||
|
@ -758,7 +758,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// touch bound regions, they just capture the in-scope
|
||||
// type/region parameters.
|
||||
let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder());
|
||||
let ty::Generator(generator_def_id, args, _) = *self_ty.kind() else {
|
||||
let ty::Coroutine(generator_def_id, args, _) = *self_ty.kind() else {
|
||||
bug!("closure candidate for non-closure {:?}", obligation);
|
||||
};
|
||||
|
||||
|
@ -1234,11 +1234,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
ty::Closure(_, args) => {
|
||||
stack.push(args.as_closure().tupled_upvars_ty());
|
||||
}
|
||||
ty::Generator(_, args, _) => {
|
||||
ty::Coroutine(_, args, _) => {
|
||||
let generator = args.as_generator();
|
||||
stack.extend([generator.tupled_upvars_ty(), generator.witness()]);
|
||||
}
|
||||
ty::GeneratorWitness(def_id, args) => {
|
||||
ty::CoroutineWitness(def_id, args) => {
|
||||
let tcx = self.tcx();
|
||||
stack.extend(tcx.generator_hidden_types(def_id).map(|bty| {
|
||||
let ty = bty.instantiate(tcx, args);
|
||||
|
|
|
@ -1886,7 +1886,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
ImplCandidate(..)
|
||||
| AutoImplCandidate
|
||||
| ClosureCandidate { .. }
|
||||
| GeneratorCandidate
|
||||
| CoroutineCandidate
|
||||
| FutureCandidate
|
||||
| FnPointerCandidate { .. }
|
||||
| BuiltinObjectCandidate
|
||||
|
@ -1914,7 +1914,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
ImplCandidate(_)
|
||||
| AutoImplCandidate
|
||||
| ClosureCandidate { .. }
|
||||
| GeneratorCandidate
|
||||
| CoroutineCandidate
|
||||
| FutureCandidate
|
||||
| FnPointerCandidate { .. }
|
||||
| BuiltinObjectCandidate
|
||||
|
@ -1948,7 +1948,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
ImplCandidate(..)
|
||||
| AutoImplCandidate
|
||||
| ClosureCandidate { .. }
|
||||
| GeneratorCandidate
|
||||
| CoroutineCandidate
|
||||
| FutureCandidate
|
||||
| FnPointerCandidate { .. }
|
||||
| BuiltinObjectCandidate
|
||||
|
@ -1962,7 +1962,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
ImplCandidate(..)
|
||||
| AutoImplCandidate
|
||||
| ClosureCandidate { .. }
|
||||
| GeneratorCandidate
|
||||
| CoroutineCandidate
|
||||
| FutureCandidate
|
||||
| FnPointerCandidate { .. }
|
||||
| BuiltinObjectCandidate
|
||||
|
@ -2068,7 +2068,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
(
|
||||
ImplCandidate(_)
|
||||
| ClosureCandidate { .. }
|
||||
| GeneratorCandidate
|
||||
| CoroutineCandidate
|
||||
| FutureCandidate
|
||||
| FnPointerCandidate { .. }
|
||||
| BuiltinObjectCandidate
|
||||
|
@ -2078,7 +2078,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
| TraitAliasCandidate,
|
||||
ImplCandidate(_)
|
||||
| ClosureCandidate { .. }
|
||||
| GeneratorCandidate
|
||||
| CoroutineCandidate
|
||||
| FutureCandidate
|
||||
| FnPointerCandidate { .. }
|
||||
| BuiltinObjectCandidate
|
||||
|
@ -2112,8 +2112,8 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
| ty::RawPtr(..)
|
||||
| ty::Char
|
||||
| ty::Ref(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Coroutine(..)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Array(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Never
|
||||
|
@ -2180,7 +2180,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
ty::Dynamic(..)
|
||||
| ty::Str
|
||||
| ty::Slice(..)
|
||||
| ty::Generator(_, _, hir::Movability::Static)
|
||||
| ty::Coroutine(_, _, hir::Movability::Static)
|
||||
| ty::Foreign(..)
|
||||
| ty::Ref(_, _, hir::Mutability::Mut) => None,
|
||||
|
||||
|
@ -2189,7 +2189,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
Where(obligation.predicate.rebind(tys.iter().collect()))
|
||||
}
|
||||
|
||||
ty::Generator(_, args, hir::Movability::Movable) => {
|
||||
ty::Coroutine(_, args, hir::Movability::Movable) => {
|
||||
if self.tcx().features().generator_clone {
|
||||
let resolved_upvars =
|
||||
self.infcx.shallow_resolve(args.as_generator().tupled_upvars_ty());
|
||||
|
@ -2212,7 +2212,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::GeneratorWitness(def_id, ref args) => {
|
||||
ty::CoroutineWitness(def_id, ref args) => {
|
||||
let hidden_types = bind_generator_hidden_types_above(
|
||||
self.infcx,
|
||||
def_id,
|
||||
|
@ -2311,13 +2311,13 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
t.rebind(vec![ty])
|
||||
}
|
||||
|
||||
ty::Generator(_, ref args, _) => {
|
||||
ty::Coroutine(_, ref args, _) => {
|
||||
let ty = self.infcx.shallow_resolve(args.as_generator().tupled_upvars_ty());
|
||||
let witness = args.as_generator().witness();
|
||||
t.rebind([ty].into_iter().chain(iter::once(witness)).collect())
|
||||
}
|
||||
|
||||
ty::GeneratorWitness(def_id, ref args) => {
|
||||
ty::CoroutineWitness(def_id, ref args) => {
|
||||
bind_generator_hidden_types_above(self.infcx, def_id, args, t.bound_vars())
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for Search<'tcx> {
|
|||
ty::Closure(..) => {
|
||||
return ControlFlow::Break(ty);
|
||||
}
|
||||
ty::Generator(..) | ty::GeneratorWitness(..) => {
|
||||
ty::Coroutine(..) | ty::CoroutineWitness(..) => {
|
||||
return ControlFlow::Break(ty);
|
||||
}
|
||||
ty::FnDef(..) => {
|
||||
|
|
|
@ -600,7 +600,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||
| ty::Float(..)
|
||||
| ty::Error(_)
|
||||
| ty::Str
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::CoroutineWitness(..)
|
||||
| ty::Never
|
||||
| ty::Param(_)
|
||||
| ty::Bound(..)
|
||||
|
@ -672,7 +672,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::Generator(did, args, ..) => {
|
||||
ty::Coroutine(did, args, ..) => {
|
||||
// Walk ALL the types in the generator: this will
|
||||
// include the upvar types as well as the yield
|
||||
// type. Note that this is mildly distinct from
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue