aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres/tests/macros.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-21 17:29:31 +0100
committerGitHub <[email protected]>2021-05-21 17:29:31 +0100
commitde403b10448e23f232804596538de92fc57203d6 (patch)
treedcf8ccdfd09d282f14e5e5c24057496caaa3a4ff /crates/hir_def/src/nameres/tests/macros.rs
parenteb08a27f1bd31cc15db4893dded60663effaf3f9 (diff)
parentd00bc9c2fc211650bf3d16b0e77fc7dac20f34c5 (diff)
Merge #8910
8910: Don't lower extern block in the ItemTree r=jonas-schievink a=jonas-schievink The ItemTree lowering code used to attach attributes on an `extern {}` block to all the children. This is wrong and causes problems with attribute resolution that manifested as a hang. This PR treats extern blocks as first-class items in the ItemTree and lowers its contents in the `ModCollector` instead. Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8414#issuecomment-845607923 Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8905 Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8909 bors r+ Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src/nameres/tests/macros.rs')
-rw-r--r--crates/hir_def/src/nameres/tests/macros.rs36
1 files changed, 36 insertions, 0 deletions
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]
739fn unresolved_attrs_extern_block_hang() {
740 check(
741 r#"
742#[unresolved]
743extern "C" {
744 #[unresolved]
745 fn f();
746}
747 "#,
748 expect![[r#"
749 crate
750 f: v
751 "#]],
752 );
753}
754
755#[test]
756fn macros_in_extern_block() {
757 check(
758 r#"
759macro_rules! m {
760 () => { static S: u8; };
761}
762
763extern {
764 m!();
765}
766 "#,
767 expect![[r#"
768 crate
769 S: v
770 "#]],
771 );
772}
773
774#[test]
739fn resolves_derive_helper() { 775fn resolves_derive_helper() {
740 cov_mark::check!(resolved_derive_helper); 776 cov_mark::check!(resolved_derive_helper);
741 check( 777 check(