aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-22 16:00:17 +0000
committerGitHub <[email protected]>2019-11-22 16:00:17 +0000
commit404493e9df8cc34fab5ff0c605eef7700e687e80 (patch)
treed7ebbde67a4253cf4e827c3f4d2e8323a26ad547
parent6d42db2e51e223c9be7b6ea234521ca6f93ee95a (diff)
parent7469d2b8631594a5ed41082f375bd4cb20538efa (diff)
Merge #2359
2359: Remove TraitData from API r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/ra_hir/src/code_model.rs13
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs2
2 files changed, 5 insertions, 10 deletions
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::{
10 adt::VariantData, 10 adt::VariantData,
11 body::scope::ExprScopes, 11 body::scope::ExprScopes,
12 builtin_type::BuiltinType, 12 builtin_type::BuiltinType,
13 data::TraitData,
14 nameres::per_ns::PerNs, 13 nameres::per_ns::PerNs,
15 resolver::{HasResolver, TypeNs}, 14 resolver::{HasResolver, TypeNs},
16 type_ref::TypeRef, 15 type_ref::TypeRef,
@@ -707,11 +706,11 @@ impl Trait {
707 } 706 }
708 707
709 pub fn name(self, db: &impl DefDatabase) -> Option<Name> { 708 pub fn name(self, db: &impl DefDatabase) -> Option<Name> {
710 self.trait_data(db).name.clone() 709 db.trait_data(self.id).name.clone()
711 } 710 }
712 711
713 pub fn items(self, db: &impl DefDatabase) -> Vec<AssocItem> { 712 pub fn items(self, db: &impl DefDatabase) -> Vec<AssocItem> {
714 self.trait_data(db).items.iter().map(|it| (*it).into()).collect() 713 db.trait_data(self.id).items.iter().map(|it| (*it).into()).collect()
715 } 714 }
716 715
717 fn direct_super_traits(self, db: &impl HirDatabase) -> Vec<Trait> { 716 fn direct_super_traits(self, db: &impl HirDatabase) -> Vec<Trait> {
@@ -757,7 +756,7 @@ impl Trait {
757 } 756 }
758 757
759 pub fn associated_type_by_name(self, db: &impl DefDatabase, name: &Name) -> Option<TypeAlias> { 758 pub fn associated_type_by_name(self, db: &impl DefDatabase, name: &Name) -> Option<TypeAlias> {
760 let trait_data = self.trait_data(db); 759 let trait_data = db.trait_data(self.id);
761 let res = 760 let res =
762 trait_data.associated_types().map(TypeAlias::from).find(|t| &t.name(db) == name)?; 761 trait_data.associated_types().map(TypeAlias::from).find(|t| &t.name(db) == name)?;
763 Some(res) 762 Some(res)
@@ -771,16 +770,12 @@ impl Trait {
771 self.all_super_traits(db).into_iter().find_map(|t| t.associated_type_by_name(db, name)) 770 self.all_super_traits(db).into_iter().find_map(|t| t.associated_type_by_name(db, name))
772 } 771 }
773 772
774 pub(crate) fn trait_data(self, db: &impl DefDatabase) -> Arc<TraitData> {
775 db.trait_data(self.id)
776 }
777
778 pub fn trait_ref(self, db: &impl HirDatabase) -> TraitRef { 773 pub fn trait_ref(self, db: &impl HirDatabase) -> TraitRef {
779 TraitRef::for_trait(db, self) 774 TraitRef::for_trait(db, self)
780 } 775 }
781 776
782 pub fn is_auto(self, db: &impl DefDatabase) -> bool { 777 pub fn is_auto(self, db: &impl DefDatabase) -> bool {
783 self.trait_data(db).auto 778 db.trait_data(self.id).auto
784 } 779 }
785} 780}
786 781
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<T>(
233 .chain(traits_from_env) 233 .chain(traits_from_env)
234 .chain(resolver.traits_in_scope(db).into_iter().map(Trait::from)); 234 .chain(resolver.traits_in_scope(db).into_iter().map(Trait::from));
235 'traits: for t in traits { 235 'traits: for t in traits {
236 let data = t.trait_data(db); 236 let data = db.trait_data(t.id);
237 237
238 // we'll be lazy about checking whether the type implements the 238 // we'll be lazy about checking whether the type implements the
239 // trait, but if we find out it doesn't, we'll skip the rest of the 239 // trait, but if we find out it doesn't, we'll skip the rest of the