Add direct_supertraits(…) HIR-level method to hir::Trait type

This commit is contained in:
Vincent Esche 2024-11-06 09:53:11 +01:00
parent c1155213f3
commit e6461522bc

View file

@ -68,7 +68,7 @@ use hir_ty::{
all_super_traits, autoderef, check_orphan_rules,
consteval::{try_const_usize, unknown_const_as_generic, ConstExt},
diagnostics::BodyValidationDiagnostic,
error_lifetime, known_const_to_ast,
direct_super_traits, error_lifetime, known_const_to_ast,
layout::{Layout as TyLayout, RustcEnumVariantIdx, RustcFieldIdx, TagEncoding},
method_resolution,
mir::{interpret_mir, MutBorrowKind},
@ -2704,6 +2704,11 @@ impl Trait {
db.trait_data(self.id).name.clone()
}
pub fn direct_supertraits(self, db: &dyn HirDatabase) -> Vec<Trait> {
let traits = direct_super_traits(db.upcast(), self.into());
traits.iter().map(|tr| Trait::from(*tr)).collect()
}
pub fn all_supertraits(self, db: &dyn HirDatabase) -> Vec<Trait> {
let traits = all_super_traits(db.upcast(), self.into());
traits.iter().map(|tr| Trait::from(*tr)).collect()