Skip to content

Commit 6f5c51f

Browse files
We don't need impl_trait_in_trait_parent_fn anymore
1 parent 44c8ab9 commit 6f5c51f

File tree

2 files changed

+4
-15
lines changed
  • compiler

2 files changed

+4
-15
lines changed

compiler/rustc_middle/src/ty/mod.rs

-13
Original file line numberDiff line numberDiff line change
@@ -2613,19 +2613,6 @@ impl<'tcx> TyCtxt<'tcx> {
26132613
matches!(self.trait_of_item(def_id), Some(trait_id) if self.has_attr(trait_id, sym::const_trait))
26142614
}
26152615

2616-
pub fn impl_trait_in_trait_parent_fn(self, mut def_id: DefId) -> DefId {
2617-
match self.opt_rpitit_info(def_id) {
2618-
Some(ImplTraitInTraitData::Trait { fn_def_id, .. })
2619-
| Some(ImplTraitInTraitData::Impl { fn_def_id, .. }) => fn_def_id,
2620-
None => {
2621-
while let def_kind = self.def_kind(def_id) && def_kind != DefKind::AssocFn {
2622-
def_id = self.parent(def_id);
2623-
}
2624-
def_id
2625-
}
2626-
}
2627-
}
2628-
26292616
/// Returns the `DefId` of the item within which the `impl Trait` is declared.
26302617
/// For type-alias-impl-trait this is the `type` alias.
26312618
/// For impl-trait-in-assoc-type this is the assoc type.

compiler/rustc_ty_utils/src/ty.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,10 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitFinder<'_, 'tcx> {
179179

180180
fn visit_ty(&mut self, ty: Ty<'tcx>) -> std::ops::ControlFlow<Self::BreakTy> {
181181
if let ty::Alias(ty::Projection, unshifted_alias_ty) = *ty.kind()
182-
&& self.tcx.is_impl_trait_in_trait(unshifted_alias_ty.def_id)
183-
&& self.tcx.impl_trait_in_trait_parent_fn(unshifted_alias_ty.def_id) == self.fn_def_id
182+
&& let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, .. }
183+
| ty::ImplTraitInTraitData::Impl { fn_def_id, .. })
184+
= self.tcx.opt_rpitit_info(unshifted_alias_ty.def_id)
185+
&& fn_def_id == self.fn_def_id
184186
&& self.seen.insert(unshifted_alias_ty.def_id)
185187
{
186188
// We have entered some binders as we've walked into the

0 commit comments

Comments
 (0)