From 94b3b32c9882ad206df4f11f2f8de0be70a615f4 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 18 Mar 2021 01:28:40 +0100 Subject: Support `#[cfg]` on all associated items --- crates/hir_def/src/data.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/hir_def') diff --git a/crates/hir_def/src/data.rs b/crates/hir_def/src/data.rs index e976e419e..2c70b3bc0 100644 --- a/crates/hir_def/src/data.rs +++ b/crates/hir_def/src/data.rs @@ -256,17 +256,17 @@ fn collect_items( let mut items = Vec::new(); for item in assoc_items { + let attrs = item_tree.attrs(db, module.krate, ModItem::from(item).into()); + if !attrs.is_cfg_enabled(&cfg_options) { + continue; + } + match item { AssocItem::Function(id) => { let item = &item_tree[id]; - let attrs = item_tree.attrs(db, module.krate, ModItem::from(id).into()); - if !attrs.is_cfg_enabled(&cfg_options) { - continue; - } let def = FunctionLoc { container, id: ItemTreeId::new(file_id, id) }.intern(db); items.push((item.name.clone(), def.into())); } - // FIXME: cfg? AssocItem::Const(id) => { let item = &item_tree[id]; let name = match item.name.clone() { -- cgit v1.2.3