From 8b94b429e5a76a0518b07111f8faf0dca7457948 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 11 Jun 2019 17:40:18 +0300 Subject: use Source for MacroDef --- crates/ra_hir/src/code_model.rs | 15 ++++++++++----- crates/ra_hir/src/docs.rs | 2 +- 2 files changed, 11 insertions(+), 6 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 5b56f890e..adb61a804 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -1003,12 +1003,17 @@ pub struct MacroDef { pub(crate) id: MacroDefId, } +impl HasSource for MacroDef { + type Ast = TreeArc; + + fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { + (self.id.0.file_id(), self.id.0.to_node(db)).into() + } +} + impl MacroDef { - pub fn source( - &self, - db: &(impl DefDatabase + AstDatabase), - ) -> (HirFileId, TreeArc) { - (self.id.0.file_id(), self.id.0.to_node(db)) + pub fn source(&self, db: &(impl DefDatabase + AstDatabase)) -> Source> { + (self.id.0.file_id(), self.id.0.to_node(db)).into() } } diff --git a/crates/ra_hir/src/docs.rs b/crates/ra_hir/src/docs.rs index f736f3875..cbf7ae10b 100644 --- a/crates/ra_hir/src/docs.rs +++ b/crates/ra_hir/src/docs.rs @@ -85,7 +85,7 @@ pub(crate) fn documentation_query( DocDef::Union(it) => docs_from_ast(&*it.source(db).ast), DocDef::Trait(it) => docs_from_ast(&*it.source(db).ast), DocDef::TypeAlias(it) => docs_from_ast(&*it.source(db).ast), - DocDef::MacroDef(it) => docs_from_ast(&*it.source(db).1), + DocDef::MacroDef(it) => docs_from_ast(&*it.source(db).ast), } } -- cgit v1.2.3