From 89826a50fc59f271b8b52ae675e145029727aa35 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 10 Oct 2019 17:42:29 +0300 Subject: don't special case path attr --- crates/ra_hir/src/nameres/raw.rs | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'crates/ra_hir/src/nameres/raw.rs') diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs index 5f93f920f..469fd8ea7 100644 --- a/crates/ra_hir/src/nameres/raw.rs +++ b/crates/ra_hir/src/nameres/raw.rs @@ -5,7 +5,7 @@ use std::{ops::Index, sync::Arc}; use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; use ra_syntax::{ ast::{self, AttrsOwner, NameOwner}, - AstNode, AstPtr, SmolStr, SourceFile, + AstNode, AstPtr, SourceFile, }; use test_utils::tested_by; @@ -152,14 +152,12 @@ pub(super) enum ModuleData { Declaration { name: Name, ast_id: FileAstId, - attr_path: Option, is_macro_use: bool, }, Definition { name: Name, ast_id: FileAstId, items: Vec, - attr_path: Option, is_macro_use: bool, }, } @@ -295,11 +293,9 @@ impl RawItemsCollector<&DB> { // FIXME: cfg_attr let is_macro_use = module.has_atom_attr("macro_use"); if module.has_semi() { - let attr_path = extract_mod_path_attribute(&module); let item = self.raw_items.modules.alloc(ModuleData::Declaration { name, ast_id, - attr_path, is_macro_use, }); self.push_item(current_module, attrs, RawItemKind::Module(item)); @@ -307,12 +303,10 @@ impl RawItemsCollector<&DB> { } if let Some(item_list) = module.item_list() { - let attr_path = extract_mod_path_attribute(&module); let item = self.raw_items.modules.alloc(ModuleData::Definition { name, ast_id, items: Vec::new(), - attr_path, is_macro_use, }); self.process_module(Some(item), item_list); @@ -423,16 +417,3 @@ impl RawItemsCollector<&DB> { Attr::from_attrs_owner(self.file_id, item, self.db) } } - -fn extract_mod_path_attribute(module: &ast::Module) -> Option { - module.attrs().into_iter().find_map(|attr| { - attr.as_simple_key_value().and_then(|(name, value)| { - let is_path = name == "path"; - if is_path { - Some(value) - } else { - None - } - }) - }) -} -- cgit v1.2.3 From 29e83988be5be6d2bc4d869f00f4bf931b1500fa Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 10 Oct 2019 17:48:30 +0300 Subject: don't special case macro_use --- crates/ra_hir/src/nameres/raw.rs | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'crates/ra_hir/src/nameres/raw.rs') diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs index 469fd8ea7..57f2929c3 100644 --- a/crates/ra_hir/src/nameres/raw.rs +++ b/crates/ra_hir/src/nameres/raw.rs @@ -149,17 +149,8 @@ impl_arena_id!(Module); #[derive(Debug, PartialEq, Eq)] pub(super) enum ModuleData { - Declaration { - name: Name, - ast_id: FileAstId, - is_macro_use: bool, - }, - Definition { - name: Name, - ast_id: FileAstId, - items: Vec, - is_macro_use: bool, - }, + Declaration { name: Name, ast_id: FileAstId }, + Definition { name: Name, ast_id: FileAstId, items: Vec }, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -290,14 +281,8 @@ impl RawItemsCollector<&DB> { let attrs = self.parse_attrs(&module); let ast_id = self.source_ast_id_map.ast_id(&module); - // FIXME: cfg_attr - let is_macro_use = module.has_atom_attr("macro_use"); if module.has_semi() { - let item = self.raw_items.modules.alloc(ModuleData::Declaration { - name, - ast_id, - is_macro_use, - }); + let item = self.raw_items.modules.alloc(ModuleData::Declaration { name, ast_id }); self.push_item(current_module, attrs, RawItemKind::Module(item)); return; } @@ -307,7 +292,6 @@ impl RawItemsCollector<&DB> { name, ast_id, items: Vec::new(), - is_macro_use, }); self.process_module(Some(item), item_list); self.push_item(current_module, attrs, RawItemKind::Module(item)); -- cgit v1.2.3