diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-03 20:15:02 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-03 20:15:02 +0100 |
commit | e96c9e4865f392e1de7ef32e244151ad97b403dc (patch) | |
tree | 237790e58b0e8a64f42ea562d2cdf454dee83b57 /crates/ra_hir/src/nameres/raw.rs | |
parent | 0ca30b6c4bb717e3cc54bfc98ffaa7a6d8c2cdfd (diff) | |
parent | 83fe7b5fcb6c60b53f9ee3126b6b7995709840d3 (diff) |
Merge #1637
1637: Resolve out of line modules inside inline module with attribute path r=matklad a=andreevlex
Fixed #1510
Fixed #1529
Co-authored-by: Alexander Andreev <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/nameres/raw.rs')
-rw-r--r-- | crates/ra_hir/src/nameres/raw.rs | 17 |
1 files changed, 14 insertions, 3 deletions
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); | |||
130 | 130 | ||
131 | #[derive(Debug, PartialEq, Eq)] | 131 | #[derive(Debug, PartialEq, Eq)] |
132 | pub(super) enum ModuleData { | 132 | pub(super) enum ModuleData { |
133 | Declaration { name: Name, ast_id: FileAstId<ast::Module>, attr_path: Option<SmolStr> }, | 133 | Declaration { |
134 | Definition { name: Name, ast_id: FileAstId<ast::Module>, items: Vec<RawItem> }, | 134 | name: Name, |
135 | ast_id: FileAstId<ast::Module>, | ||
136 | attr_path: Option<SmolStr>, | ||
137 | }, | ||
138 | Definition { | ||
139 | name: Name, | ||
140 | ast_id: FileAstId<ast::Module>, | ||
141 | items: Vec<RawItem>, | ||
142 | attr_path: Option<SmolStr>, | ||
143 | }, | ||
135 | } | 144 | } |
136 | 145 | ||
137 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 146 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
@@ -256,9 +265,9 @@ impl RawItemsCollector { | |||
256 | None => return, | 265 | None => return, |
257 | }; | 266 | }; |
258 | 267 | ||
259 | let attr_path = extract_mod_path_attribute(&module); | ||
260 | let ast_id = self.source_ast_id_map.ast_id(&module); | 268 | let ast_id = self.source_ast_id_map.ast_id(&module); |
261 | if module.has_semi() { | 269 | if module.has_semi() { |
270 | let attr_path = extract_mod_path_attribute(&module); | ||
262 | let item = | 271 | let item = |
263 | self.raw_items.modules.alloc(ModuleData::Declaration { name, ast_id, attr_path }); | 272 | self.raw_items.modules.alloc(ModuleData::Declaration { name, ast_id, attr_path }); |
264 | self.push_item(current_module, RawItem::Module(item)); | 273 | self.push_item(current_module, RawItem::Module(item)); |
@@ -266,10 +275,12 @@ impl RawItemsCollector { | |||
266 | } | 275 | } |
267 | 276 | ||
268 | if let Some(item_list) = module.item_list() { | 277 | if let Some(item_list) = module.item_list() { |
278 | let attr_path = extract_mod_path_attribute(&module); | ||
269 | let item = self.raw_items.modules.alloc(ModuleData::Definition { | 279 | let item = self.raw_items.modules.alloc(ModuleData::Definition { |
270 | name, | 280 | name, |
271 | ast_id, | 281 | ast_id, |
272 | items: Vec::new(), | 282 | items: Vec::new(), |
283 | attr_path, | ||
273 | }); | 284 | }); |
274 | self.process_module(Some(item), item_list); | 285 | self.process_module(Some(item), item_list); |
275 | self.push_item(current_module, RawItem::Module(item)); | 286 | self.push_item(current_module, RawItem::Module(item)); |