diff options
author | cynecx <[email protected]> | 2021-04-14 01:36:05 +0100 |
---|---|---|
committer | cynecx <[email protected]> | 2021-04-17 15:24:56 +0100 |
commit | 14918a3870d568778473f0a5697a547b85acf20a (patch) | |
tree | 0d8811909d721ddecc3277893b8df874ead68ddd /crates/hir_def/src | |
parent | 28ef7c20d79803403be58eeffa18ab1fb21e261c (diff) |
hir_def: ignore ast::Type in file_item_tree query
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r-- | crates/hir_def/src/item_tree.rs | 5 | ||||
-rw-r--r-- | crates/hir_def/src/item_tree/lower.rs | 16 |
2 files changed, 11 insertions, 10 deletions
diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs index 94e08f835..fed285505 100644 --- a/crates/hir_def/src/item_tree.rs +++ b/crates/hir_def/src/item_tree.rs | |||
@@ -104,6 +104,11 @@ impl ItemTree { | |||
104 | // items and expanded during block DefMap computation | 104 | // items and expanded during block DefMap computation |
105 | return Default::default(); | 105 | return Default::default(); |
106 | }, | 106 | }, |
107 | ast::Type(_ty) => { | ||
108 | // FIXME: This occurs because macros in type position are treated as inner | ||
109 | // items and expanded during block DefMap computation | ||
110 | return Default::default(); | ||
111 | }, | ||
107 | ast::Expr(e) => { | 112 | ast::Expr(e) => { |
108 | // Macros can expand to expressions. We return an empty item tree in this case, but | 113 | // Macros can expand to expressions. We return an empty item tree in this case, but |
109 | // still need to collect inner items. | 114 | // still need to collect inner items. |
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index 2975786dd..45b099cf3 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs | |||
@@ -189,16 +189,12 @@ impl Ctx { | |||
189 | block_stack.push(self.source_ast_id_map.ast_id(&block)); | 189 | block_stack.push(self.source_ast_id_map.ast_id(&block)); |
190 | }, | 190 | }, |
191 | ast::Item(item) => { | 191 | ast::Item(item) => { |
192 | // FIXME: This triggers for macro calls in expression/pattern | 192 | // FIXME: This triggers for macro calls in expression/pattern/type position |
193 | if let Some(SyntaxKind::MACRO_TYPE) = node.parent().map(|p| p.kind()) { | 193 | let mod_items = self.lower_mod_item(&item, true); |
194 | // Ignore macros at type position | 194 | let current_block = block_stack.last(); |
195 | } else { | 195 | if let (Some(mod_items), Some(block)) = (mod_items, current_block) { |
196 | let mod_items = self.lower_mod_item(&item, true); | 196 | if !mod_items.0.is_empty() { |
197 | let current_block = block_stack.last(); | 197 | self.data().inner_items.entry(*block).or_default().extend(mod_items.0.iter().copied()); |
198 | if let (Some(mod_items), Some(block)) = (mod_items, current_block) { | ||
199 | if !mod_items.0.is_empty() { | ||
200 | self.data().inner_items.entry(*block).or_default().extend(mod_items.0.iter().copied()); | ||
201 | } | ||
202 | } | 198 | } |
203 | } | 199 | } |
204 | }, | 200 | }, |