aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/data.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/data.rs')
-rw-r--r--crates/ra_hir_def/src/data.rs21
1 files changed, 10 insertions, 11 deletions
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs
index d4cba4d05..e7eb2bb11 100644
--- a/crates/ra_hir_def/src/data.rs
+++ b/crates/ra_hir_def/src/data.rs
@@ -9,7 +9,7 @@ use hir_expand::{
9}; 9};
10use ra_prof::profile; 10use ra_prof::profile;
11use ra_syntax::ast::{ 11use ra_syntax::ast::{
12 self, AstNode, ImplItem, ModuleItemOwner, NameOwner, TypeAscriptionOwner, TypeBoundsOwner, 12 self, AssocItem, AstNode, ModuleItemOwner, NameOwner, TypeAscriptionOwner, TypeBoundsOwner,
13 VisibilityOwner, 13 VisibilityOwner,
14}; 14};
15 15
@@ -164,7 +164,7 @@ impl TraitData {
164 items.extend(collect_items( 164 items.extend(collect_items(
165 db, 165 db,
166 &mut expander, 166 &mut expander,
167 item_list.impl_items(), 167 item_list.assoc_items(),
168 src.file_id, 168 src.file_id,
169 container, 169 container,
170 )); 170 ));
@@ -219,7 +219,7 @@ 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_items(db, &mut expander, item_list.impl_items(), src.file_id, container) 222 collect_items(db, &mut expander, item_list.assoc_items(), src.file_id, container)
223 .into_iter() 223 .into_iter()
224 .map(|(_, item)| item), 224 .map(|(_, item)| item),
225 ); 225 );
@@ -304,7 +304,7 @@ fn collect_items_in_macro(
304 let mut res = collect_items( 304 let mut res = collect_items(
305 db, 305 db,
306 expander, 306 expander,
307 items.value.items().filter_map(|it| ImplItem::cast(it.syntax().clone())), 307 items.value.items().filter_map(|it| AssocItem::cast(it.syntax().clone())),
308 items.file_id, 308 items.file_id,
309 container, 309 container,
310 ); 310 );
@@ -325,31 +325,30 @@ fn collect_items_in_macro(
325fn collect_items( 325fn collect_items(
326 db: &dyn DefDatabase, 326 db: &dyn DefDatabase,
327 expander: &mut Expander, 327 expander: &mut Expander,
328 impl_items: impl Iterator<Item = ImplItem>, 328 assoc_items: impl Iterator<Item = AssocItem>,
329 file_id: crate::HirFileId, 329 file_id: crate::HirFileId,
330 container: AssocContainerId, 330 container: AssocContainerId,
331) -> Vec<(Name, AssocItemId)> { 331) -> Vec<(Name, AssocItemId)> {
332 let items = db.ast_id_map(file_id); 332 let items = db.ast_id_map(file_id);
333 333
334 impl_items 334 assoc_items
335 .filter_map(|item_node| match item_node { 335 .filter_map(|item_node| match item_node {
336 ast::ImplItem::FnDef(it) => { 336 ast::AssocItem::FnDef(it) => {
337 let name = it.name().map_or_else(Name::missing, |it| it.as_name()); 337 let name = it.name().map_or_else(Name::missing, |it| it.as_name());
338 let attrs = expander.parse_attrs(&it); 338 if !expander.is_cfg_enabled(&it) {
339 if !expander.is_cfg_enabled(&attrs) {
340 return None; 339 return None;
341 } 340 }
342 let def = FunctionLoc { container, ast_id: AstId::new(file_id, items.ast_id(&it)) } 341 let def = FunctionLoc { container, ast_id: AstId::new(file_id, items.ast_id(&it)) }
343 .intern(db); 342 .intern(db);
344 Some((name, def.into())) 343 Some((name, def.into()))
345 } 344 }
346 ast::ImplItem::ConstDef(it) => { 345 ast::AssocItem::ConstDef(it) => {
347 let name = it.name().map_or_else(Name::missing, |it| it.as_name()); 346 let name = it.name().map_or_else(Name::missing, |it| it.as_name());
348 let def = ConstLoc { container, ast_id: AstId::new(file_id, items.ast_id(&it)) } 347 let def = ConstLoc { container, ast_id: AstId::new(file_id, items.ast_id(&it)) }
349 .intern(db); 348 .intern(db);
350 Some((name, def.into())) 349 Some((name, def.into()))
351 } 350 }
352 ast::ImplItem::TypeAliasDef(it) => { 351 ast::AssocItem::TypeAliasDef(it) => {
353 let name = it.name().map_or_else(Name::missing, |it| it.as_name()); 352 let name = it.name().map_or_else(Name::missing, |it| it.as_name());
354 let def = 353 let def =
355 TypeAliasLoc { container, ast_id: AstId::new(file_id, items.ast_id(&it)) } 354 TypeAliasLoc { container, ast_id: AstId::new(file_id, items.ast_id(&it)) }