mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Remove TraitData from API
This commit is contained in:
parent
fe119fef27
commit
7469d2b863
2 changed files with 5 additions and 10 deletions
|
@ -10,7 +10,6 @@ use hir_def::{
|
||||||
adt::VariantData,
|
adt::VariantData,
|
||||||
body::scope::ExprScopes,
|
body::scope::ExprScopes,
|
||||||
builtin_type::BuiltinType,
|
builtin_type::BuiltinType,
|
||||||
data::TraitData,
|
|
||||||
nameres::per_ns::PerNs,
|
nameres::per_ns::PerNs,
|
||||||
resolver::{HasResolver, TypeNs},
|
resolver::{HasResolver, TypeNs},
|
||||||
type_ref::TypeRef,
|
type_ref::TypeRef,
|
||||||
|
@ -707,11 +706,11 @@ impl Trait {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(self, db: &impl DefDatabase) -> Option<Name> {
|
pub fn name(self, db: &impl DefDatabase) -> Option<Name> {
|
||||||
self.trait_data(db).name.clone()
|
db.trait_data(self.id).name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn items(self, db: &impl DefDatabase) -> Vec<AssocItem> {
|
pub fn items(self, db: &impl DefDatabase) -> Vec<AssocItem> {
|
||||||
self.trait_data(db).items.iter().map(|it| (*it).into()).collect()
|
db.trait_data(self.id).items.iter().map(|it| (*it).into()).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn direct_super_traits(self, db: &impl HirDatabase) -> Vec<Trait> {
|
fn direct_super_traits(self, db: &impl HirDatabase) -> Vec<Trait> {
|
||||||
|
@ -757,7 +756,7 @@ impl Trait {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn associated_type_by_name(self, db: &impl DefDatabase, name: &Name) -> Option<TypeAlias> {
|
pub fn associated_type_by_name(self, db: &impl DefDatabase, name: &Name) -> Option<TypeAlias> {
|
||||||
let trait_data = self.trait_data(db);
|
let trait_data = db.trait_data(self.id);
|
||||||
let res =
|
let res =
|
||||||
trait_data.associated_types().map(TypeAlias::from).find(|t| &t.name(db) == name)?;
|
trait_data.associated_types().map(TypeAlias::from).find(|t| &t.name(db) == name)?;
|
||||||
Some(res)
|
Some(res)
|
||||||
|
@ -771,16 +770,12 @@ impl Trait {
|
||||||
self.all_super_traits(db).into_iter().find_map(|t| t.associated_type_by_name(db, name))
|
self.all_super_traits(db).into_iter().find_map(|t| t.associated_type_by_name(db, name))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn trait_data(self, db: &impl DefDatabase) -> Arc<TraitData> {
|
|
||||||
db.trait_data(self.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn trait_ref(self, db: &impl HirDatabase) -> TraitRef {
|
pub fn trait_ref(self, db: &impl HirDatabase) -> TraitRef {
|
||||||
TraitRef::for_trait(db, self)
|
TraitRef::for_trait(db, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_auto(self, db: &impl DefDatabase) -> bool {
|
pub fn is_auto(self, db: &impl DefDatabase) -> bool {
|
||||||
self.trait_data(db).auto
|
db.trait_data(self.id).auto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,7 @@ fn iterate_trait_method_candidates<T>(
|
||||||
.chain(traits_from_env)
|
.chain(traits_from_env)
|
||||||
.chain(resolver.traits_in_scope(db).into_iter().map(Trait::from));
|
.chain(resolver.traits_in_scope(db).into_iter().map(Trait::from));
|
||||||
'traits: for t in traits {
|
'traits: for t in traits {
|
||||||
let data = t.trait_data(db);
|
let data = db.trait_data(t.id);
|
||||||
|
|
||||||
// we'll be lazy about checking whether the type implements the
|
// we'll be lazy about checking whether the type implements the
|
||||||
// trait, but if we find out it doesn't, we'll skip the rest of the
|
// trait, but if we find out it doesn't, we'll skip the rest of the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue