diff options
author | Aleksey Kladov <[email protected]> | 2020-04-11 16:09:50 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-04-11 16:09:50 +0100 |
commit | e9519e103573e22ea0b461c81edd8cfc001e6a50 (patch) | |
tree | a8f65b8ef027f296804939cab6f18ff3571c0a92 /crates/ra_hir_def/src/data.rs | |
parent | 6b0870d12efd868202cfca45da651d21f2441031 (diff) |
Pull Expander up
Diffstat (limited to 'crates/ra_hir_def/src/data.rs')
-rw-r--r-- | crates/ra_hir_def/src/data.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index b8fbf0ed4..dd0e679e8 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs | |||
@@ -20,7 +20,7 @@ use crate::{ | |||
20 | type_ref::{Mutability, TypeBound, TypeRef}, | 20 | type_ref::{Mutability, TypeBound, TypeRef}, |
21 | visibility::RawVisibility, | 21 | visibility::RawVisibility, |
22 | AssocContainerId, AssocItemId, ConstId, ConstLoc, Expander, FunctionId, FunctionLoc, HasModule, | 22 | AssocContainerId, AssocItemId, ConstId, ConstLoc, Expander, FunctionId, FunctionLoc, HasModule, |
23 | ImplId, Intern, Lookup, ModuleId, StaticId, TraitId, TypeAliasId, TypeAliasLoc, | 23 | ImplId, Intern, Lookup, StaticId, TraitId, TypeAliasId, TypeAliasLoc, |
24 | }; | 24 | }; |
25 | 25 | ||
26 | #[derive(Debug, Clone, PartialEq, Eq)] | 26 | #[derive(Debug, Clone, PartialEq, Eq)] |
@@ -218,10 +218,11 @@ impl ImplData { | |||
218 | let mut items = Vec::new(); | 218 | let mut items = Vec::new(); |
219 | 219 | ||
220 | if let Some(item_list) = src.value.item_list() { | 220 | if let Some(item_list) = src.value.item_list() { |
221 | let mut expander = Expander::new(db, impl_loc.ast_id.file_id, module_id); | ||
221 | items.extend(collect_impl_items(db, item_list.impl_items(), src.file_id, id)); | 222 | items.extend(collect_impl_items(db, item_list.impl_items(), src.file_id, id)); |
222 | items.extend(collect_impl_items_in_macros( | 223 | items.extend(collect_impl_items_in_macros( |
223 | db, | 224 | db, |
224 | module_id, | 225 | &mut expander, |
225 | &src.with_value(item_list), | 226 | &src.with_value(item_list), |
226 | id, | 227 | id, |
227 | )); | 228 | )); |
@@ -268,18 +269,17 @@ impl ConstData { | |||
268 | 269 | ||
269 | fn collect_impl_items_in_macros( | 270 | fn collect_impl_items_in_macros( |
270 | db: &dyn DefDatabase, | 271 | db: &dyn DefDatabase, |
271 | module_id: ModuleId, | 272 | expander: &mut Expander, |
272 | impl_def: &InFile<ast::ItemList>, | 273 | impl_def: &InFile<ast::ItemList>, |
273 | id: ImplId, | 274 | id: ImplId, |
274 | ) -> Vec<AssocItemId> { | 275 | ) -> Vec<AssocItemId> { |
275 | let mut expander = Expander::new(db, impl_def.file_id, module_id); | ||
276 | let mut res = Vec::new(); | 276 | let mut res = Vec::new(); |
277 | 277 | ||
278 | // We set a limit to protect against infinite recursion | 278 | // We set a limit to protect against infinite recursion |
279 | let limit = 100; | 279 | let limit = 100; |
280 | 280 | ||
281 | for m in impl_def.value.syntax().children().filter_map(ast::MacroCall::cast) { | 281 | for m in impl_def.value.syntax().children().filter_map(ast::MacroCall::cast) { |
282 | res.extend(collect_impl_items_in_macro(db, &mut expander, m, id, limit)) | 282 | res.extend(collect_impl_items_in_macro(db, expander, m, id, limit)) |
283 | } | 283 | } |
284 | 284 | ||
285 | res | 285 | res |