diff options
-rw-r--r-- | crates/ra_hir/src/code_model/src.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ids.rs | 9 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/collector.rs | 5 |
3 files changed, 11 insertions, 5 deletions
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index c0cb27b47..dc964e156 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs | |||
@@ -119,7 +119,7 @@ impl HasSource for TypeAlias { | |||
119 | impl HasSource for MacroDef { | 119 | impl HasSource for MacroDef { |
120 | type Ast = ast::MacroCall; | 120 | type Ast = ast::MacroCall; |
121 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::MacroCall> { | 121 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::MacroCall> { |
122 | Source { file_id: self.id.0.file_id(), ast: self.id.0.to_node(db) } | 122 | Source { file_id: self.id.ast_id.file_id(), ast: self.id.ast_id.to_node(db) } |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index 9ea4e695d..246377100 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs | |||
@@ -10,7 +10,7 @@ use ra_syntax::{ast, AstNode, Parse, SyntaxNode}; | |||
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | db::{AstDatabase, DefDatabase, InternDatabase}, | 12 | db::{AstDatabase, DefDatabase, InternDatabase}, |
13 | AstId, FileAstId, Module, Source, | 13 | AstId, Crate, FileAstId, Module, Source, |
14 | }; | 14 | }; |
15 | 15 | ||
16 | /// hir makes heavy use of ids: integer (u32) handlers to various things. You | 16 | /// hir makes heavy use of ids: integer (u32) handlers to various things. You |
@@ -121,10 +121,13 @@ impl From<FileId> for HirFileId { | |||
121 | } | 121 | } |
122 | 122 | ||
123 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 123 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
124 | pub struct MacroDefId(pub(crate) AstId<ast::MacroCall>); | 124 | pub struct MacroDefId { |
125 | pub(crate) ast_id: AstId<ast::MacroCall>, | ||
126 | pub(crate) krate: Crate, | ||
127 | } | ||
125 | 128 | ||
126 | pub(crate) fn macro_def_query(db: &impl AstDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> { | 129 | pub(crate) fn macro_def_query(db: &impl AstDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> { |
127 | let macro_call = id.0.to_node(db); | 130 | let macro_call = id.ast_id.to_node(db); |
128 | let arg = macro_call.token_tree()?; | 131 | let arg = macro_call.token_tree()?; |
129 | let (tt, _) = mbe::ast_to_token_tree(&arg).or_else(|| { | 132 | let (tt, _) = mbe::ast_to_token_tree(&arg).or_else(|| { |
130 | log::warn!("fail on macro_def to token tree: {:#?}", arg); | 133 | log::warn!("fail on macro_def to token tree: {:#?}", arg); |
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index ef7dc6ebe..65929c522 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs | |||
@@ -662,7 +662,10 @@ where | |||
662 | // Case 1: macro rules, define a macro in crate-global mutable scope | 662 | // Case 1: macro rules, define a macro in crate-global mutable scope |
663 | if is_macro_rules(&mac.path) { | 663 | if is_macro_rules(&mac.path) { |
664 | if let Some(name) = &mac.name { | 664 | if let Some(name) = &mac.name { |
665 | let macro_id = MacroDefId(mac.ast_id.with_file_id(self.file_id)); | 665 | let macro_id = MacroDefId { |
666 | ast_id: mac.ast_id.with_file_id(self.file_id), | ||
667 | krate: self.def_collector.def_map.krate, | ||
668 | }; | ||
666 | let macro_ = MacroDef { id: macro_id }; | 669 | let macro_ = MacroDef { id: macro_id }; |
667 | self.def_collector.define_macro(self.module_id, name.clone(), macro_, mac.export); | 670 | self.def_collector.define_macro(self.module_id, name.clone(), macro_, mac.export); |
668 | } | 671 | } |