supertrait_def_ids

This commit is contained in:
Michael Goulet 2024-06-27 12:06:47 -04:00
parent 81c2c57519
commit c9870cfa4b
1 changed files with 2 additions and 3 deletions

View File

@ -2443,7 +2443,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// Given the def_id of a Trait `trait_def_id` and the name of an associated item `assoc_name`
/// returns true if the `trait_def_id` defines an associated item of name `assoc_name`.
pub fn trait_may_define_assoc_item(self, trait_def_id: DefId, assoc_name: Ident) -> bool {
self.super_traits_of(trait_def_id).any(|trait_did| {
self.supertrait_def_ids(trait_def_id).any(|trait_did| {
self.associated_items(trait_did)
.filter_by_name_unhygienic(assoc_name.name)
.any(|item| self.hygienic_eq(assoc_name, item.ident(self), trait_did))
@ -2467,8 +2467,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// Computes the def-ids of the transitive supertraits of `trait_def_id`. This (intentionally)
/// does not compute the full elaborated super-predicates but just the set of def-ids. It is used
/// to identify which traits may define a given associated type to help avoid cycle errors.
/// Returns a `DefId` iterator.
fn super_traits_of(self, trait_def_id: DefId) -> impl Iterator<Item = DefId> + 'tcx {
fn supertrait_def_ids(self, trait_def_id: DefId) -> impl Iterator<Item = DefId> + 'tcx {
let mut set = FxHashSet::default();
let mut stack = vec![trait_def_id];