From 83fe7b5fcb6c60b53f9ee3126b6b7995709840d3 Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Sat, 3 Aug 2019 19:44:59 +0300 Subject: Resolve out of line modules inside inline module with attribute path Fixed #1510 Fixed #1529 --- crates/ra_hir/src/nameres/raw.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 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 8517f3c43..584e15e29 100644 --- a/crates/ra_hir/src/nameres/raw.rs +++ b/crates/ra_hir/src/nameres/raw.rs @@ -130,8 +130,17 @@ impl_arena_id!(Module); #[derive(Debug, PartialEq, Eq)] pub(super) enum ModuleData { - Declaration { name: Name, ast_id: FileAstId, attr_path: Option }, - Definition { name: Name, ast_id: FileAstId, items: Vec }, + Declaration { + name: Name, + ast_id: FileAstId, + attr_path: Option, + }, + Definition { + name: Name, + ast_id: FileAstId, + items: Vec, + attr_path: Option, + }, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -256,9 +265,9 @@ impl RawItemsCollector { None => return, }; - let attr_path = extract_mod_path_attribute(&module); let ast_id = self.source_ast_id_map.ast_id(&module); 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 }); self.push_item(current_module, RawItem::Module(item)); @@ -266,10 +275,12 @@ impl RawItemsCollector { } 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, }); self.process_module(Some(item), item_list); self.push_item(current_module, RawItem::Module(item)); -- cgit v1.2.3