diff options
author | Jonas Schievink <[email protected]> | 2021-05-21 17:27:25 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2021-05-21 17:27:25 +0100 |
commit | d00bc9c2fc211650bf3d16b0e77fc7dac20f34c5 (patch) | |
tree | dcf8ccdfd09d282f14e5e5c24057496caaa3a4ff /crates/hir_def/src/nameres | |
parent | eb08a27f1bd31cc15db4893dded60663effaf3f9 (diff) |
Don't lower extern block in the ItemTree
Diffstat (limited to 'crates/hir_def/src/nameres')
-rw-r--r-- | crates/hir_def/src/nameres/collector.rs | 1 | ||||
-rw-r--r-- | crates/hir_def/src/nameres/tests/macros.rs | 36 |
2 files changed, 37 insertions, 0 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index e76d039b8..fa4b135fd 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -1243,6 +1243,7 @@ impl ModCollector<'_, '_> { | |||
1243 | status: PartialResolvedImport::Unresolved, | 1243 | status: PartialResolvedImport::Unresolved, |
1244 | }) | 1244 | }) |
1245 | } | 1245 | } |
1246 | ModItem::ExternBlock(block) => self.collect(&self.item_tree[block].children), | ||
1246 | ModItem::MacroCall(mac) => self.collect_macro_call(&self.item_tree[mac]), | 1247 | ModItem::MacroCall(mac) => self.collect_macro_call(&self.item_tree[mac]), |
1247 | ModItem::MacroRules(id) => self.collect_macro_rules(id), | 1248 | ModItem::MacroRules(id) => self.collect_macro_rules(id), |
1248 | ModItem::MacroDef(id) => self.collect_macro_def(id), | 1249 | ModItem::MacroDef(id) => self.collect_macro_def(id), |
diff --git a/crates/hir_def/src/nameres/tests/macros.rs b/crates/hir_def/src/nameres/tests/macros.rs index 04de107f5..133b2d818 100644 --- a/crates/hir_def/src/nameres/tests/macros.rs +++ b/crates/hir_def/src/nameres/tests/macros.rs | |||
@@ -736,6 +736,42 @@ fn unresolved_attributes_fall_back_track_per_file_moditems() { | |||
736 | } | 736 | } |
737 | 737 | ||
738 | #[test] | 738 | #[test] |
739 | fn unresolved_attrs_extern_block_hang() { | ||
740 | check( | ||
741 | r#" | ||
742 | #[unresolved] | ||
743 | extern "C" { | ||
744 | #[unresolved] | ||
745 | fn f(); | ||
746 | } | ||
747 | "#, | ||
748 | expect![[r#" | ||
749 | crate | ||
750 | f: v | ||
751 | "#]], | ||
752 | ); | ||
753 | } | ||
754 | |||
755 | #[test] | ||
756 | fn macros_in_extern_block() { | ||
757 | check( | ||
758 | r#" | ||
759 | macro_rules! m { | ||
760 | () => { static S: u8; }; | ||
761 | } | ||
762 | |||
763 | extern { | ||
764 | m!(); | ||
765 | } | ||
766 | "#, | ||
767 | expect![[r#" | ||
768 | crate | ||
769 | S: v | ||
770 | "#]], | ||
771 | ); | ||
772 | } | ||
773 | |||
774 | #[test] | ||
739 | fn resolves_derive_helper() { | 775 | fn resolves_derive_helper() { |
740 | cov_mark::check!(resolved_derive_helper); | 776 | cov_mark::check!(resolved_derive_helper); |
741 | check( | 777 | check( |