s/Generator/Coroutine/

This commit is contained in:
Oli Scherer
2023-10-19 16:06:43 +00:00
parent 96027d945b
commit 60956837cf
310 changed files with 1271 additions and 1271 deletions

View File

@@ -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(..)

View File

@@ -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);

View File

@@ -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())
}