diff options
Diffstat (limited to 'crates/hir_expand/src')
-rw-r--r-- | crates/hir_expand/src/hygiene.rs | 2 | ||||
-rw-r--r-- | crates/hir_expand/src/lib.rs | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/crates/hir_expand/src/hygiene.rs b/crates/hir_expand/src/hygiene.rs index 20cda1683..0e0f7214a 100644 --- a/crates/hir_expand/src/hygiene.rs +++ b/crates/hir_expand/src/hygiene.rs | |||
@@ -145,7 +145,7 @@ fn make_hygiene_info( | |||
145 | ) -> Option<HygieneInfo> { | 145 | ) -> Option<HygieneInfo> { |
146 | let arg_tt = loc.kind.arg(db)?; | 146 | let arg_tt = loc.kind.arg(db)?; |
147 | 147 | ||
148 | let def_offset = loc.def.ast_id().and_then(|id| { | 148 | let def_offset = loc.def.ast_id().left().and_then(|id| { |
149 | let def_tt = match id.to_node(db) { | 149 | let def_tt = match id.to_node(db) { |
150 | ast::Macro::MacroRules(mac) => mac.token_tree()?.syntax().text_range().start(), | 150 | ast::Macro::MacroRules(mac) => mac.token_tree()?.syntax().text_range().start(), |
151 | ast::Macro::MacroDef(_) => return None, | 151 | ast::Macro::MacroDef(_) => return None, |
diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs index c958b0865..f49fd4fda 100644 --- a/crates/hir_expand/src/lib.rs +++ b/crates/hir_expand/src/lib.rs | |||
@@ -15,6 +15,7 @@ pub mod proc_macro; | |||
15 | pub mod quote; | 15 | pub mod quote; |
16 | pub mod eager; | 16 | pub mod eager; |
17 | 17 | ||
18 | use either::Either; | ||
18 | pub use mbe::{ExpandError, ExpandResult}; | 19 | pub use mbe::{ExpandError, ExpandResult}; |
19 | 20 | ||
20 | use std::hash::Hash; | 21 | use std::hash::Hash; |
@@ -143,7 +144,7 @@ impl HirFileId { | |||
143 | 144 | ||
144 | let arg_tt = loc.kind.arg(db)?; | 145 | let arg_tt = loc.kind.arg(db)?; |
145 | 146 | ||
146 | let def = loc.def.ast_id().and_then(|id| { | 147 | let def = loc.def.ast_id().left().and_then(|id| { |
147 | let def_tt = match id.to_node(db) { | 148 | let def_tt = match id.to_node(db) { |
148 | ast::Macro::MacroRules(mac) => mac.token_tree()?, | 149 | ast::Macro::MacroRules(mac) => mac.token_tree()?, |
149 | ast::Macro::MacroDef(_) => return None, | 150 | ast::Macro::MacroDef(_) => return None, |
@@ -239,15 +240,15 @@ impl MacroDefId { | |||
239 | db.intern_macro(MacroCallLoc { def: self, krate, kind }) | 240 | db.intern_macro(MacroCallLoc { def: self, krate, kind }) |
240 | } | 241 | } |
241 | 242 | ||
242 | pub fn ast_id(&self) -> Option<AstId<ast::Macro>> { | 243 | pub fn ast_id(&self) -> Either<AstId<ast::Macro>, AstId<ast::Fn>> { |
243 | let id = match &self.kind { | 244 | let id = match &self.kind { |
244 | MacroDefKind::Declarative(id) => id, | 245 | MacroDefKind::Declarative(id) => id, |
245 | MacroDefKind::BuiltIn(_, id) => id, | 246 | MacroDefKind::BuiltIn(_, id) => id, |
246 | MacroDefKind::BuiltInDerive(_, id) => id, | 247 | MacroDefKind::BuiltInDerive(_, id) => id, |
247 | MacroDefKind::BuiltInEager(_, id) => id, | 248 | MacroDefKind::BuiltInEager(_, id) => id, |
248 | MacroDefKind::ProcMacro(..) => return None, | 249 | MacroDefKind::ProcMacro(_, id) => return Either::Right(*id), |
249 | }; | 250 | }; |
250 | Some(*id) | 251 | Either::Left(*id) |
251 | } | 252 | } |
252 | } | 253 | } |
253 | 254 | ||