diff options
Diffstat (limited to 'crates/ra_hir_expand/src/lib.rs')
-rw-r--r-- | crates/ra_hir_expand/src/lib.rs | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index 21d666f13..c6ffa2c6f 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs | |||
@@ -78,15 +78,9 @@ impl HirFileId { | |||
78 | HirFileIdRepr::MacroFile(macro_file) => { | 78 | HirFileIdRepr::MacroFile(macro_file) => { |
79 | let loc: MacroCallLoc = db.lookup_intern_macro(macro_file.macro_call_id); | 79 | let loc: MacroCallLoc = db.lookup_intern_macro(macro_file.macro_call_id); |
80 | 80 | ||
81 | // FIXME: Do we support expansion information in builtin macro? | ||
82 | let macro_decl = match loc.def { | ||
83 | MacroDefId::DeclarativeMacro(it) => (it), | ||
84 | MacroDefId::BuiltinMacro(_) => return None, | ||
85 | }; | ||
86 | |||
87 | let arg_start = loc.ast_id.to_node(db).token_tree()?.syntax().text_range().start(); | 81 | let arg_start = loc.ast_id.to_node(db).token_tree()?.syntax().text_range().start(); |
88 | let def_start = | 82 | let def_start = |
89 | macro_decl.ast_id.to_node(db).token_tree()?.syntax().text_range().start(); | 83 | loc.def.ast_id.to_node(db).token_tree()?.syntax().text_range().start(); |
90 | 84 | ||
91 | let macro_def = db.macro_def(loc.def)?; | 85 | let macro_def = db.macro_def(loc.def)?; |
92 | let shift = macro_def.0.shift(); | 86 | let shift = macro_def.0.shift(); |
@@ -94,7 +88,7 @@ impl HirFileId { | |||
94 | let macro_arg = db.macro_arg(macro_file.macro_call_id)?; | 88 | let macro_arg = db.macro_arg(macro_file.macro_call_id)?; |
95 | 89 | ||
96 | let arg_start = (loc.ast_id.file_id, arg_start); | 90 | let arg_start = (loc.ast_id.file_id, arg_start); |
97 | let def_start = (macro_decl.ast_id.file_id, def_start); | 91 | let def_start = (loc.def.ast_id.file_id, def_start); |
98 | 92 | ||
99 | Some(ExpansionInfo { arg_start, def_start, macro_arg, macro_def, exp_map, shift }) | 93 | Some(ExpansionInfo { arg_start, def_start, macro_arg, macro_def, exp_map, shift }) |
100 | } | 94 | } |
@@ -128,22 +122,16 @@ impl salsa::InternKey for MacroCallId { | |||
128 | } | 122 | } |
129 | 123 | ||
130 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 124 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
131 | pub enum MacroDefId { | 125 | pub struct MacroDefId { |
132 | DeclarativeMacro(DeclarativeMacro), | ||
133 | BuiltinMacro(BuiltinMacro), | ||
134 | } | ||
135 | |||
136 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
137 | pub struct DeclarativeMacro { | ||
138 | pub krate: CrateId, | 126 | pub krate: CrateId, |
139 | pub ast_id: AstId<ast::MacroCall>, | 127 | pub ast_id: AstId<ast::MacroCall>, |
128 | pub kind: MacroDefKind, | ||
140 | } | 129 | } |
141 | 130 | ||
142 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 131 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
143 | pub struct BuiltinMacro { | 132 | pub enum MacroDefKind { |
144 | pub krate: CrateId, | 133 | Declarative, |
145 | pub ast_id: AstId<ast::MacroCall>, | 134 | BuiltIn(BuiltinExpander), |
146 | pub expander: BuiltinExpander, | ||
147 | } | 135 | } |
148 | 136 | ||
149 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 137 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |