aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-06-11 15:43:36 +0100
committerAleksey Kladov <[email protected]>2019-06-11 16:28:51 +0100
commit178d8e96b5c810f40e7dd282ab06bb25d1fc8a2a (patch)
tree6ce44285c249ef6a7f8803a3be2de579f97ba766 /crates/ra_hir/src
parent8b94b429e5a76a0518b07111f8faf0dca7457948 (diff)
use Source for StructField
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/code_model.rs11
-rw-r--r--crates/ra_hir/src/docs.rs2
2 files changed, 10 insertions, 3 deletions
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 {
346 Pos(TreeArc<ast::PosFieldDef>), 346 Pos(TreeArc<ast::PosFieldDef>),
347} 347}
348 348
349impl HasSource for StructField {
350 type Ast = FieldSource;
351 fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<FieldSource> {
352 self.source_impl(db).into()
353 }
354}
355
349impl StructField { 356impl StructField {
350 pub fn name(&self, db: &impl HirDatabase) -> Name { 357 pub fn name(&self, db: &impl HirDatabase) -> Name {
351 self.parent.variant_data(db).fields().unwrap()[self.id].name.clone() 358 self.parent.variant_data(db).fields().unwrap()[self.id].name.clone()
352 } 359 }
353 360
354 pub fn source(&self, db: &(impl DefDatabase + AstDatabase)) -> (HirFileId, FieldSource) { 361 pub fn source(&self, db: &(impl DefDatabase + AstDatabase)) -> Source<FieldSource> {
355 self.source_impl(db) 362 self.source_impl(db).into()
356 } 363 }
357 364
358 pub fn ty(&self, db: &impl HirDatabase) -> Ty { 365 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(
72) -> Option<Documentation> { 72) -> Option<Documentation> {
73 match def { 73 match def {
74 DocDef::Module(it) => docs_from_ast(&*it.declaration_source(db)?.1), 74 DocDef::Module(it) => docs_from_ast(&*it.declaration_source(db)?.1),
75 DocDef::StructField(it) => match it.source(db).1 { 75 DocDef::StructField(it) => match it.source(db).ast {
76 FieldSource::Named(named) => docs_from_ast(&*named), 76 FieldSource::Named(named) => docs_from_ast(&*named),
77 FieldSource::Pos(..) => return None, 77 FieldSource::Pos(..) => return None,
78 }, 78 },