Clean up implementation of RPITIT assoc item lowering

This commit is contained in:
Michael Goulet
2025-07-12 19:31:15 +00:00
parent 47e15d90e1
commit 736bfa12de
9 changed files with 110 additions and 146 deletions

View File

@@ -15,7 +15,6 @@ use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::{
self, BottomUpFolder, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeFoldable, TypeFolder,
TypeSuperFoldable, TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode, Upcast,
associated_types_for_impl_traits_in_associated_fn,
};
use rustc_middle::{bug, span_bug};
use rustc_span::{DUMMY_SP, Span};
@@ -758,7 +757,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
// returning `-> Missing<impl Sized>`, that gets converted to `-> {type error}`,
// and when walking through the signature we end up never collecting the def id
// of the `impl Sized`. Insert that here, so we don't ICE later.
for assoc_item in associated_types_for_impl_traits_in_associated_fn(tcx, trait_m.def_id) {
for assoc_item in tcx.associated_types_for_impl_traits_in_associated_fn(trait_m.def_id) {
if !remapped_types.contains_key(assoc_item) {
remapped_types.insert(
*assoc_item,
@@ -2449,7 +2448,8 @@ fn param_env_with_gat_bounds<'tcx>(
ty::ImplTraitInTraitData::Impl { fn_def_id }
| ty::ImplTraitInTraitData::Trait { fn_def_id, .. },
),
} => associated_types_for_impl_traits_in_associated_fn(tcx, fn_def_id)
} => tcx
.associated_types_for_impl_traits_in_associated_fn(fn_def_id)
.iter()
.map(|def_id| tcx.associated_item(*def_id))
.collect(),

View File

@@ -20,7 +20,7 @@ use rustc_middle::ty::trait_def::TraitSpecializationKind;
use rustc_middle::ty::{
self, AdtKind, GenericArgKind, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeFlags,
TypeFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode,
Upcast, associated_types_for_impl_traits_in_associated_fn,
Upcast,
};
use rustc_middle::{bug, span_bug};
use rustc_session::parse::feature_err;
@@ -327,7 +327,7 @@ pub(crate) fn check_trait_item<'tcx>(
if matches!(tcx.def_kind(def_id), DefKind::AssocFn) {
for &assoc_ty_def_id in
associated_types_for_impl_traits_in_associated_fn(tcx, def_id.to_def_id())
tcx.associated_types_for_impl_traits_in_associated_fn(def_id.to_def_id())
{
res = res.and(check_associated_item(tcx, assoc_ty_def_id.expect_local()));
}