From 178d8e96b5c810f40e7dd282ab06bb25d1fc8a2a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 11 Jun 2019 17:43:36 +0300 Subject: use Source for StructField --- crates/ra_hir/src/code_model.rs | 11 +++++++++-- crates/ra_hir/src/docs.rs | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index adb61a804..4c121503e 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -346,13 +346,20 @@ pub enum FieldSource { Pos(TreeArc), } +impl HasSource for StructField { + type Ast = FieldSource; + fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source { + self.source_impl(db).into() + } +} + impl StructField { pub fn name(&self, db: &impl HirDatabase) -> Name { self.parent.variant_data(db).fields().unwrap()[self.id].name.clone() } - pub fn source(&self, db: &(impl DefDatabase + AstDatabase)) -> (HirFileId, FieldSource) { - self.source_impl(db) + pub fn source(&self, db: &(impl DefDatabase + AstDatabase)) -> Source { + self.source_impl(db).into() } pub fn ty(&self, db: &impl HirDatabase) -> Ty { diff --git a/crates/ra_hir/src/docs.rs b/crates/ra_hir/src/docs.rs index cbf7ae10b..ae82d55a5 100644 --- a/crates/ra_hir/src/docs.rs +++ b/crates/ra_hir/src/docs.rs @@ -72,7 +72,7 @@ pub(crate) fn documentation_query( ) -> Option { match def { DocDef::Module(it) => docs_from_ast(&*it.declaration_source(db)?.1), - DocDef::StructField(it) => match it.source(db).1 { + DocDef::StructField(it) => match it.source(db).ast { FieldSource::Named(named) => docs_from_ast(&*named), FieldSource::Pos(..) => return None, }, -- cgit v1.2.3