diff options
author | Jonas Schievink <[email protected]> | 2021-03-19 18:56:13 +0000 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2021-03-19 18:56:13 +0000 |
commit | 93aeb16eb21709de38ba8484fa82ed4e05ae5665 (patch) | |
tree | 6f4808ef6a79fa816d6b03d18234f27a0ed59c42 /crates/hir/src | |
parent | 0392e63c95736e988bda0fc62261ef48e89b3a31 (diff) |
Return `Either` from `MacroDefId::ast_id`
Diffstat (limited to 'crates/hir/src')
-rw-r--r-- | crates/hir/src/has_source.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/crates/hir/src/has_source.rs b/crates/hir/src/has_source.rs index d57fad9ed..dc10a4d0f 100644 --- a/crates/hir/src/has_source.rs +++ b/crates/hir/src/has_source.rs | |||
@@ -6,7 +6,7 @@ use hir_def::{ | |||
6 | src::{HasChildSource, HasSource as _}, | 6 | src::{HasChildSource, HasSource as _}, |
7 | Lookup, VariantId, | 7 | Lookup, VariantId, |
8 | }; | 8 | }; |
9 | use hir_expand::{InFile, MacroDefKind}; | 9 | use hir_expand::InFile; |
10 | use syntax::ast; | 10 | use syntax::ast; |
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
@@ -113,15 +113,10 @@ impl HasSource for TypeAlias { | |||
113 | impl HasSource for MacroDef { | 113 | impl HasSource for MacroDef { |
114 | type Ast = Either<ast::Macro, ast::Fn>; | 114 | type Ast = Either<ast::Macro, ast::Fn>; |
115 | fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { | 115 | fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> { |
116 | Some(match &self.id.kind { | 116 | Some(self.id.ast_id().either( |
117 | MacroDefKind::Declarative(id) | 117 | |id| id.with_value(Either::Left(id.to_node(db.upcast()))), |
118 | | MacroDefKind::BuiltIn(_, id) | 118 | |id| id.with_value(Either::Right(id.to_node(db.upcast()))), |
119 | | MacroDefKind::BuiltInDerive(_, id) | 119 | )) |
120 | | MacroDefKind::BuiltInEager(_, id) => { | ||
121 | id.with_value(Either::Left(id.to_node(db.upcast()))) | ||
122 | } | ||
123 | MacroDefKind::ProcMacro(_, id) => id.map(|_| Either::Right(id.to_node(db.upcast()))), | ||
124 | }) | ||
125 | } | 120 | } |
126 | } | 121 | } |
127 | impl HasSource for Impl { | 122 | impl HasSource for Impl { |