aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir_def/src/data.rs39
1 files changed, 14 insertions, 25 deletions
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs
index 0633eddee..d4cba4d05 100644
--- a/crates/ra_hir_def/src/data.rs
+++ b/crates/ra_hir_def/src/data.rs
@@ -161,14 +161,14 @@ impl TraitData {
161 161
162 if let Some(item_list) = src.value.item_list() { 162 if let Some(item_list) = src.value.item_list() {
163 let mut expander = Expander::new(db, tr_loc.ast_id.file_id, module_id); 163 let mut expander = Expander::new(db, tr_loc.ast_id.file_id, module_id);
164 items.extend(collect_impl_items( 164 items.extend(collect_items(
165 db, 165 db,
166 &mut expander, 166 &mut expander,
167 item_list.impl_items(), 167 item_list.impl_items(),
168 src.file_id, 168 src.file_id,
169 container, 169 container,
170 )); 170 ));
171 items.extend(collect_impl_items_in_macros( 171 items.extend(collect_items_in_macros(
172 db, 172 db,
173 &mut expander, 173 &mut expander,
174 &src.with_value(item_list), 174 &src.with_value(item_list),
@@ -219,25 +219,14 @@ impl ImplData {
219 if let Some(item_list) = src.value.item_list() { 219 if let Some(item_list) = src.value.item_list() {
220 let mut expander = Expander::new(db, impl_loc.ast_id.file_id, module_id); 220 let mut expander = Expander::new(db, impl_loc.ast_id.file_id, module_id);
221 items.extend( 221 items.extend(
222 collect_impl_items( 222 collect_items(db, &mut expander, item_list.impl_items(), src.file_id, container)
223 db, 223 .into_iter()
224 &mut expander, 224 .map(|(_, item)| item),
225 item_list.impl_items(),
226 src.file_id,
227 container,
228 )
229 .into_iter()
230 .map(|(_, item)| item),
231 ); 225 );
232 items.extend( 226 items.extend(
233 collect_impl_items_in_macros( 227 collect_items_in_macros(db, &mut expander, &src.with_value(item_list), container)
234 db, 228 .into_iter()
235 &mut expander, 229 .map(|(_, item)| item),
236 &src.with_value(item_list),
237 container,
238 )
239 .into_iter()
240 .map(|(_, item)| item),
241 ); 230 );
242 } 231 }
243 232
@@ -281,7 +270,7 @@ impl ConstData {
281 } 270 }
282} 271}
283 272
284fn collect_impl_items_in_macros( 273fn collect_items_in_macros(
285 db: &dyn DefDatabase, 274 db: &dyn DefDatabase,
286 expander: &mut Expander, 275 expander: &mut Expander,
287 impl_def: &InFile<ast::ItemList>, 276 impl_def: &InFile<ast::ItemList>,
@@ -293,13 +282,13 @@ fn collect_impl_items_in_macros(
293 let limit = 100; 282 let limit = 100;
294 283
295 for m in impl_def.value.syntax().children().filter_map(ast::MacroCall::cast) { 284 for m in impl_def.value.syntax().children().filter_map(ast::MacroCall::cast) {
296 res.extend(collect_impl_items_in_macro(db, expander, m, container, limit)) 285 res.extend(collect_items_in_macro(db, expander, m, container, limit))
297 } 286 }
298 287
299 res 288 res
300} 289}
301 290
302fn collect_impl_items_in_macro( 291fn collect_items_in_macro(
303 db: &dyn DefDatabase, 292 db: &dyn DefDatabase,
304 expander: &mut Expander, 293 expander: &mut Expander,
305 m: ast::MacroCall, 294 m: ast::MacroCall,
@@ -312,7 +301,7 @@ fn collect_impl_items_in_macro(
312 301
313 if let Some((mark, items)) = expander.enter_expand(db, None, m) { 302 if let Some((mark, items)) = expander.enter_expand(db, None, m) {
314 let items: InFile<ast::MacroItems> = expander.to_source(items); 303 let items: InFile<ast::MacroItems> = expander.to_source(items);
315 let mut res = collect_impl_items( 304 let mut res = collect_items(
316 db, 305 db,
317 expander, 306 expander,
318 items.value.items().filter_map(|it| ImplItem::cast(it.syntax().clone())), 307 items.value.items().filter_map(|it| ImplItem::cast(it.syntax().clone())),
@@ -324,7 +313,7 @@ fn collect_impl_items_in_macro(
324 // Note that ast::ModuleItem do not include ast::MacroCall 313 // Note that ast::ModuleItem do not include ast::MacroCall
325 // We cannot use ModuleItemOwner::items here 314 // We cannot use ModuleItemOwner::items here
326 for it in items.value.syntax().children().filter_map(ast::MacroCall::cast) { 315 for it in items.value.syntax().children().filter_map(ast::MacroCall::cast) {
327 res.extend(collect_impl_items_in_macro(db, expander, it, container, limit - 1)) 316 res.extend(collect_items_in_macro(db, expander, it, container, limit - 1))
328 } 317 }
329 expander.exit(db, mark); 318 expander.exit(db, mark);
330 res 319 res
@@ -333,7 +322,7 @@ fn collect_impl_items_in_macro(
333 } 322 }
334} 323}
335 324
336fn collect_impl_items( 325fn collect_items(
337 db: &dyn DefDatabase, 326 db: &dyn DefDatabase,
338 expander: &mut Expander, 327 expander: &mut Expander,
339 impl_items: impl Iterator<Item = ImplItem>, 328 impl_items: impl Iterator<Item = ImplItem>,