Some more coroutine renamings

This commit is contained in:
Michael Goulet 2023-10-30 23:35:35 +00:00
parent 31bc7e2c47
commit add09e66f2
16 changed files with 85 additions and 76 deletions

View file

@ -564,7 +564,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
G::consider_builtin_future_candidate(self, goal)
} else if lang_items.iterator_trait() == Some(trait_def_id) {
G::consider_builtin_iterator_candidate(self, goal)
} else if lang_items.gen_trait() == Some(trait_def_id) {
} else if lang_items.coroutine_trait() == Some(trait_def_id) {
G::consider_builtin_coroutine_candidate(self, goal)
} else if lang_items.discriminant_kind_trait() == Some(trait_def_id) {
G::consider_builtin_discriminant_kind_candidate(self, goal)

View file

@ -1648,7 +1648,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}
fn describe_coroutine(&self, body_id: hir::BodyId) -> Option<&'static str> {
self.tcx.hir().body(body_id).coroutine_kind.map(|gen_kind| match gen_kind {
self.tcx.hir().body(body_id).coroutine_kind.map(|coroutine_source| match coroutine_source {
hir::CoroutineKind::Coroutine => "a coroutine",
hir::CoroutineKind::Async(hir::CoroutineSource::Block) => "an async block",
hir::CoroutineKind::Async(hir::CoroutineSource::Fn) => "an async function",
@ -3187,7 +3187,8 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
// traits manually, but don't make it more confusing when it does
// happen.
Some(
if Some(expected_trait_ref.def_id()) != self.tcx.lang_items().gen_trait() && not_tupled
if Some(expected_trait_ref.def_id()) != self.tcx.lang_items().coroutine_trait()
&& not_tupled
{
self.report_and_explain_type_error(
TypeTrace::poly_trait_refs(

View file

@ -1798,7 +1798,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
let self_ty = selcx.infcx.shallow_resolve(obligation.predicate.self_ty());
let lang_items = selcx.tcx().lang_items();
if [lang_items.gen_trait(), lang_items.future_trait(), lang_items.iterator_trait()].contains(&Some(trait_ref.def_id))
if [lang_items.coroutine_trait(), lang_items.future_trait(), lang_items.iterator_trait()].contains(&Some(trait_ref.def_id))
|| selcx.tcx().fn_trait_kind_from_def_id(trait_ref.def_id).is_some()
{
true
@ -2011,7 +2011,7 @@ fn confirm_select_candidate<'cx, 'tcx>(
ImplSource::Builtin(BuiltinImplSource::Misc, data) => {
let trait_def_id = obligation.predicate.trait_def_id(selcx.tcx());
let lang_items = selcx.tcx().lang_items();
if lang_items.gen_trait() == Some(trait_def_id) {
if lang_items.coroutine_trait() == Some(trait_def_id) {
confirm_coroutine_candidate(selcx, obligation, data)
} else if lang_items.future_trait() == Some(trait_def_id) {
confirm_future_candidate(selcx, obligation, data)
@ -2051,26 +2051,26 @@ fn confirm_coroutine_candidate<'cx, 'tcx>(
else {
unreachable!()
};
let gen_sig = args.as_coroutine().poly_sig();
let Normalized { value: gen_sig, obligations } = normalize_with_depth(
let coroutine_sig = args.as_coroutine().poly_sig();
let Normalized { value: coroutine_sig, obligations } = normalize_with_depth(
selcx,
obligation.param_env,
obligation.cause.clone(),
obligation.recursion_depth + 1,
gen_sig,
coroutine_sig,
);
debug!(?obligation, ?gen_sig, ?obligations, "confirm_coroutine_candidate");
debug!(?obligation, ?coroutine_sig, ?obligations, "confirm_coroutine_candidate");
let tcx = selcx.tcx();
let gen_def_id = tcx.require_lang_item(LangItem::Coroutine, None);
let coroutine_def_id = tcx.require_lang_item(LangItem::Coroutine, None);
let predicate = super::util::coroutine_trait_ref_and_outputs(
tcx,
gen_def_id,
coroutine_def_id,
obligation.predicate.self_ty(),
gen_sig,
coroutine_sig,
)
.map_bound(|(trait_ref, yield_ty, return_ty)| {
let name = tcx.associated_item(obligation.predicate.def_id).name;
@ -2103,16 +2103,16 @@ fn confirm_future_candidate<'cx, 'tcx>(
else {
unreachable!()
};
let gen_sig = args.as_coroutine().poly_sig();
let Normalized { value: gen_sig, obligations } = normalize_with_depth(
let coroutine_sig = args.as_coroutine().poly_sig();
let Normalized { value: coroutine_sig, obligations } = normalize_with_depth(
selcx,
obligation.param_env,
obligation.cause.clone(),
obligation.recursion_depth + 1,
gen_sig,
coroutine_sig,
);
debug!(?obligation, ?gen_sig, ?obligations, "confirm_future_candidate");
debug!(?obligation, ?coroutine_sig, ?obligations, "confirm_future_candidate");
let tcx = selcx.tcx();
let fut_def_id = tcx.require_lang_item(LangItem::Future, None);
@ -2121,7 +2121,7 @@ fn confirm_future_candidate<'cx, 'tcx>(
tcx,
fut_def_id,
obligation.predicate.self_ty(),
gen_sig,
coroutine_sig,
)
.map_bound(|(trait_ref, return_ty)| {
debug_assert_eq!(tcx.associated_item(obligation.predicate.def_id).name, sym::Output);
@ -2156,7 +2156,7 @@ fn confirm_iterator_candidate<'cx, 'tcx>(
gen_sig,
);
debug!(?obligation, ?gen_sig, ?obligations, "confirm_future_candidate");
debug!(?obligation, ?gen_sig, ?obligations, "confirm_iterator_candidate");
let tcx = selcx.tcx();
let iter_def_id = tcx.require_lang_item(LangItem::Iterator, None);

View file

@ -109,7 +109,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
self.assemble_builtin_bound_candidates(clone_conditions, &mut candidates);
}
if lang_items.gen_trait() == Some(def_id) {
if lang_items.coroutine_trait() == Some(def_id) {
self.assemble_coroutine_candidates(obligation, &mut candidates);
} else if lang_items.future_trait() == Some(def_id) {
self.assemble_future_candidates(obligation, &mut candidates);

View file

@ -730,7 +730,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
debug!(?obligation, ?coroutine_def_id, ?args, "confirm_coroutine_candidate");
let gen_sig = args.as_coroutine().poly_sig();
let coroutine_sig = args.as_coroutine().poly_sig();
// NOTE: The self-type is a coroutine type and hence is
// in fact unparameterized (or at least does not reference any
@ -745,7 +745,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
self.tcx(),
obligation.predicate.def_id(),
self_ty,
gen_sig,
coroutine_sig,
)
.map_bound(|(trait_ref, ..)| trait_ref);
@ -769,13 +769,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
debug!(?obligation, ?coroutine_def_id, ?args, "confirm_future_candidate");
let gen_sig = args.as_coroutine().poly_sig();
let coroutine_sig = args.as_coroutine().poly_sig();
let trait_ref = super::util::future_trait_ref_and_outputs(
self.tcx(),
obligation.predicate.def_id(),
obligation.predicate.no_bound_vars().expect("future has no bound vars").self_ty(),
gen_sig,
coroutine_sig,
)
.map_bound(|(trait_ref, ..)| trait_ref);