diff options
author | Lukas Wirth <[email protected]> | 2021-01-31 18:26:04 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-01-31 18:33:02 +0000 |
commit | 412f180d71bb942dcda5afaa7d6dc2ad6f463d61 (patch) | |
tree | 20420c6ff4f67e09395700d4877e797cda865820 /crates/hir_def/src/nameres/collector.rs | |
parent | 286d90de2d213b467a092e702edf8b0706c7c1b2 (diff) |
Honor #![macro_use] in mod source files
Diffstat (limited to 'crates/hir_def/src/nameres/collector.rs')
-rw-r--r-- | crates/hir_def/src/nameres/collector.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index ae98fadac..fcc8e2607 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -1273,12 +1273,8 @@ impl ModCollector<'_, '_> { | |||
1273 | // out of line module, resolve, parse and recurse | 1273 | // out of line module, resolve, parse and recurse |
1274 | ModKind::Outline {} => { | 1274 | ModKind::Outline {} => { |
1275 | let ast_id = AstId::new(self.file_id, module.ast_id); | 1275 | let ast_id = AstId::new(self.file_id, module.ast_id); |
1276 | match self.mod_dir.resolve_declaration( | 1276 | let db = self.def_collector.db; |
1277 | self.def_collector.db, | 1277 | match self.mod_dir.resolve_declaration(db, self.file_id, &module.name, path_attr) { |
1278 | self.file_id, | ||
1279 | &module.name, | ||
1280 | path_attr, | ||
1281 | ) { | ||
1282 | Ok((file_id, is_mod_rs, mod_dir)) => { | 1278 | Ok((file_id, is_mod_rs, mod_dir)) => { |
1283 | let module_id = self.push_child_module( | 1279 | let module_id = self.push_child_module( |
1284 | module.name.clone(), | 1280 | module.name.clone(), |
@@ -1286,7 +1282,7 @@ impl ModCollector<'_, '_> { | |||
1286 | Some((file_id, is_mod_rs)), | 1282 | Some((file_id, is_mod_rs)), |
1287 | &self.item_tree[module.visibility], | 1283 | &self.item_tree[module.visibility], |
1288 | ); | 1284 | ); |
1289 | let item_tree = self.def_collector.db.item_tree(file_id.into()); | 1285 | let item_tree = db.item_tree(file_id.into()); |
1290 | ModCollector { | 1286 | ModCollector { |
1291 | def_collector: &mut *self.def_collector, | 1287 | def_collector: &mut *self.def_collector, |
1292 | macro_depth: self.macro_depth, | 1288 | macro_depth: self.macro_depth, |
@@ -1296,7 +1292,12 @@ impl ModCollector<'_, '_> { | |||
1296 | mod_dir, | 1292 | mod_dir, |
1297 | } | 1293 | } |
1298 | .collect(item_tree.top_level_items()); | 1294 | .collect(item_tree.top_level_items()); |
1299 | if is_macro_use { | 1295 | if is_macro_use |
1296 | || item_tree | ||
1297 | .top_level_attrs(db, self.def_collector.def_map.krate) | ||
1298 | .by_key("macro_use") | ||
1299 | .exists() | ||
1300 | { | ||
1300 | self.import_all_legacy_macros(module_id); | 1301 | self.import_all_legacy_macros(module_id); |
1301 | } | 1302 | } |
1302 | } | 1303 | } |