From 7469d2b8631594a5ed41082f375bd4cb20538efa Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 22 Nov 2019 18:53:39 +0300 Subject: Remove TraitData from API --- crates/ra_hir/src/code_model.rs | 13 ++++--------- crates/ra_hir/src/ty/method_resolution.rs | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index af07b2c4d..9f8c6c4a5 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -10,7 +10,6 @@ use hir_def::{ adt::VariantData, body::scope::ExprScopes, builtin_type::BuiltinType, - data::TraitData, nameres::per_ns::PerNs, resolver::{HasResolver, TypeNs}, type_ref::TypeRef, @@ -707,11 +706,11 @@ impl Trait { } pub fn name(self, db: &impl DefDatabase) -> Option { - self.trait_data(db).name.clone() + db.trait_data(self.id).name.clone() } pub fn items(self, db: &impl DefDatabase) -> Vec { - 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 { @@ -757,7 +756,7 @@ impl Trait { } pub fn associated_type_by_name(self, db: &impl DefDatabase, name: &Name) -> Option { - let trait_data = self.trait_data(db); + let trait_data = db.trait_data(self.id); let res = trait_data.associated_types().map(TypeAlias::from).find(|t| &t.name(db) == name)?; 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)) } - pub(crate) fn trait_data(self, db: &impl DefDatabase) -> Arc { - db.trait_data(self.id) - } - pub fn trait_ref(self, db: &impl HirDatabase) -> TraitRef { TraitRef::for_trait(db, self) } pub fn is_auto(self, db: &impl DefDatabase) -> bool { - self.trait_data(db).auto + db.trait_data(self.id).auto } } diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index f84aae26e..f61c27218 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs @@ -233,7 +233,7 @@ fn iterate_trait_method_candidates( .chain(traits_from_env) .chain(resolver.traits_in_scope(db).into_iter().map(Trait::from)); '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 // trait, but if we find out it doesn't, we'll skip the rest of the -- cgit v1.2.3