diff options
Diffstat (limited to 'crates/hir_def/src/nameres/tests/macros.rs')
-rw-r--r-- | crates/hir_def/src/nameres/tests/macros.rs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/crates/hir_def/src/nameres/tests/macros.rs b/crates/hir_def/src/nameres/tests/macros.rs index 6eb5f97be..3065efd65 100644 --- a/crates/hir_def/src/nameres/tests/macros.rs +++ b/crates/hir_def/src/nameres/tests/macros.rs | |||
@@ -736,6 +736,80 @@ 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 | // Regression test for https://github.com/rust-analyzer/rust-analyzer/issues/8905 | ||
741 | check( | ||
742 | r#" | ||
743 | #[unresolved] | ||
744 | extern "C" { | ||
745 | #[unresolved] | ||
746 | fn f(); | ||
747 | } | ||
748 | "#, | ||
749 | expect![[r#" | ||
750 | crate | ||
751 | f: v | ||
752 | "#]], | ||
753 | ); | ||
754 | } | ||
755 | |||
756 | #[test] | ||
757 | fn macros_in_extern_block() { | ||
758 | check( | ||
759 | r#" | ||
760 | macro_rules! m { | ||
761 | () => { static S: u8; }; | ||
762 | } | ||
763 | |||
764 | extern { | ||
765 | m!(); | ||
766 | } | ||
767 | "#, | ||
768 | expect![[r#" | ||
769 | crate | ||
770 | S: v | ||
771 | "#]], | ||
772 | ); | ||
773 | } | ||
774 | |||
775 | #[test] | ||
776 | fn resolves_derive_helper() { | ||
777 | cov_mark::check!(resolved_derive_helper); | ||
778 | check( | ||
779 | r#" | ||
780 | //- /main.rs crate:main deps:proc | ||
781 | #[derive(proc::Derive)] | ||
782 | #[helper] | ||
783 | #[unresolved] | ||
784 | struct S; | ||
785 | |||
786 | //- /proc.rs crate:proc | ||
787 | #[proc_macro_derive(Derive, attributes(helper))] | ||
788 | fn derive() {} | ||
789 | "#, | ||
790 | expect![[r#" | ||
791 | crate | ||
792 | S: t v | ||
793 | "#]], | ||
794 | ); | ||
795 | } | ||
796 | |||
797 | #[test] | ||
798 | fn unresolved_attr_with_cfg_attr_hang() { | ||
799 | // Another regression test for https://github.com/rust-analyzer/rust-analyzer/issues/8905 | ||
800 | check( | ||
801 | r#" | ||
802 | #[cfg_attr(not(off), unresolved, unresolved)] | ||
803 | struct S; | ||
804 | "#, | ||
805 | expect![[r#" | ||
806 | crate | ||
807 | S: t v | ||
808 | "#]], | ||
809 | ); | ||
810 | } | ||
811 | |||
812 | #[test] | ||
739 | fn macro_expansion_overflow() { | 813 | fn macro_expansion_overflow() { |
740 | cov_mark::check!(macro_expansion_overflow); | 814 | cov_mark::check!(macro_expansion_overflow); |
741 | check( | 815 | check( |