diff options
author | Aleksey Kladov <[email protected]> | 2019-10-10 15:16:02 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-10-10 15:23:01 +0100 |
commit | b36b8970ccefa7c98f827caebf6dda71ff3d99c4 (patch) | |
tree | 5b8b4ecc6cc829429e2a753ecca5f6440c4ae92d /crates/ra_hir/src/nameres/collector.rs | |
parent | 8bcf40115fbb802c8853dcf3c70fc626f6d1a404 (diff) |
simplify a bit
Diffstat (limited to 'crates/ra_hir/src/nameres/collector.rs')
-rw-r--r-- | crates/ra_hir/src/nameres/collector.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index 88aee7437..5dacdb0d9 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs | |||
@@ -7,6 +7,7 @@ use rustc_hash::FxHashMap; | |||
7 | use test_utils::tested_by; | 7 | use test_utils::tested_by; |
8 | 8 | ||
9 | use crate::{ | 9 | use crate::{ |
10 | attr::Attr, | ||
10 | db::DefDatabase, | 11 | db::DefDatabase, |
11 | ids::{AstItemDef, LocationCtx, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind}, | 12 | ids::{AstItemDef, LocationCtx, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind}, |
12 | name::MACRO_RULES, | 13 | name::MACRO_RULES, |
@@ -532,7 +533,7 @@ where | |||
532 | // `#[macro_use] extern crate` is hoisted to imports macros before collecting | 533 | // `#[macro_use] extern crate` is hoisted to imports macros before collecting |
533 | // any other items. | 534 | // any other items. |
534 | for item in items { | 535 | for item in items { |
535 | if self.is_cfg_enabled(&item.attrs) { | 536 | if self.is_cfg_enabled(item.attrs()) { |
536 | if let raw::RawItemKind::Import(import_id) = item.kind { | 537 | if let raw::RawItemKind::Import(import_id) = item.kind { |
537 | let import = self.raw_items[import_id].clone(); | 538 | let import = self.raw_items[import_id].clone(); |
538 | if import.is_extern_crate && import.is_macro_use { | 539 | if import.is_extern_crate && import.is_macro_use { |
@@ -543,7 +544,7 @@ where | |||
543 | } | 544 | } |
544 | 545 | ||
545 | for item in items { | 546 | for item in items { |
546 | if self.is_cfg_enabled(&item.attrs) { | 547 | if self.is_cfg_enabled(item.attrs()) { |
547 | match item.kind { | 548 | match item.kind { |
548 | raw::RawItemKind::Module(m) => self.collect_module(&self.raw_items[m]), | 549 | raw::RawItemKind::Module(m) => self.collect_module(&self.raw_items[m]), |
549 | raw::RawItemKind::Import(import_id) => self | 550 | raw::RawItemKind::Import(import_id) => self |
@@ -709,12 +710,8 @@ where | |||
709 | } | 710 | } |
710 | } | 711 | } |
711 | 712 | ||
712 | fn is_cfg_enabled(&self, attrs: &raw::Attrs) -> bool { | 713 | fn is_cfg_enabled(&self, attrs: &[Attr]) -> bool { |
713 | attrs.as_ref().map_or(true, |attrs| { | 714 | attrs.iter().all(|attr| attr.is_cfg_enabled(&self.def_collector.cfg_options) != Some(false)) |
714 | attrs | ||
715 | .iter() | ||
716 | .all(|attr| attr.is_cfg_enabled(&self.def_collector.cfg_options) != Some(false)) | ||
717 | }) | ||
718 | } | 715 | } |
719 | } | 716 | } |
720 | 717 | ||