diff options
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index aa6eb741b..a8a0875e0 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -761,12 +761,17 @@ pub struct Const { | |||
761 | pub(crate) id: ConstId, | 761 | pub(crate) id: ConstId, |
762 | } | 762 | } |
763 | 763 | ||
764 | impl HasSource for Const { | ||
765 | type Ast = TreeArc<ast::ConstDef>; | ||
766 | |||
767 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::ConstDef>> { | ||
768 | self.id.source(db).into() | ||
769 | } | ||
770 | } | ||
771 | |||
764 | impl Const { | 772 | impl Const { |
765 | pub fn source( | 773 | pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::ConstDef>> { |
766 | self, | 774 | self.id.source(db).into() |
767 | db: &(impl DefDatabase + AstDatabase), | ||
768 | ) -> (HirFileId, TreeArc<ast::ConstDef>) { | ||
769 | self.id.source(db) | ||
770 | } | 775 | } |
771 | 776 | ||
772 | pub fn module(self, db: &impl DefDatabase) -> Module { | 777 | pub fn module(self, db: &impl DefDatabase) -> Module { |
@@ -819,7 +824,7 @@ impl ConstSignature { | |||
819 | db: &(impl DefDatabase + AstDatabase), | 824 | db: &(impl DefDatabase + AstDatabase), |
820 | konst: Const, | 825 | konst: Const, |
821 | ) -> Arc<ConstSignature> { | 826 | ) -> Arc<ConstSignature> { |
822 | let (_, node) = konst.source(db); | 827 | let node = konst.source(db).ast; |
823 | const_signature_for(&*node) | 828 | const_signature_for(&*node) |
824 | } | 829 | } |
825 | 830 | ||
@@ -827,7 +832,7 @@ impl ConstSignature { | |||
827 | db: &(impl DefDatabase + AstDatabase), | 832 | db: &(impl DefDatabase + AstDatabase), |
828 | konst: Static, | 833 | konst: Static, |
829 | ) -> Arc<ConstSignature> { | 834 | ) -> Arc<ConstSignature> { |
830 | let (_, node) = konst.source(db); | 835 | let node = konst.source(db).ast; |
831 | const_signature_for(&*node) | 836 | const_signature_for(&*node) |
832 | } | 837 | } |
833 | } | 838 | } |
@@ -844,12 +849,17 @@ pub struct Static { | |||
844 | pub(crate) id: StaticId, | 849 | pub(crate) id: StaticId, |
845 | } | 850 | } |
846 | 851 | ||
852 | impl HasSource for Static { | ||
853 | type Ast = TreeArc<ast::StaticDef>; | ||
854 | |||
855 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::StaticDef>> { | ||
856 | self.id.source(db).into() | ||
857 | } | ||
858 | } | ||
859 | |||
847 | impl Static { | 860 | impl Static { |
848 | pub fn source( | 861 | pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::StaticDef>> { |
849 | self, | 862 | self.id.source(db).into() |
850 | db: &(impl DefDatabase + AstDatabase), | ||
851 | ) -> (HirFileId, TreeArc<ast::StaticDef>) { | ||
852 | self.id.source(db) | ||
853 | } | 863 | } |
854 | 864 | ||
855 | pub fn module(self, db: &impl DefDatabase) -> Module { | 865 | pub fn module(self, db: &impl DefDatabase) -> Module { |