aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def')
-rw-r--r--crates/hir_def/src/nameres/tests/macros.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/hir_def/src/nameres/tests/macros.rs b/crates/hir_def/src/nameres/tests/macros.rs
index f65a655bf..d59d3c0db 100644
--- a/crates/hir_def/src/nameres/tests/macros.rs
+++ b/crates/hir_def/src/nameres/tests/macros.rs
@@ -1,4 +1,5 @@
1use super::*; 1use super::*;
2use crate::nameres::proc_macro::{ProcMacroDef, ProcMacroKind};
2 3
3#[test] 4#[test]
4fn macro_rules_are_globally_visible() { 5fn macro_rules_are_globally_visible() {
@@ -790,3 +791,28 @@ fn proc_macro_censoring() {
790 "#]], 791 "#]],
791 ); 792 );
792} 793}
794
795#[test]
796fn collects_derive_helpers() {
797 let def_map = compute_crate_def_map(
798 r"
799 struct TokenStream;
800
801 #[proc_macro_derive(AnotherTrait, attributes(helper_attr))]
802 pub fn derive_macro_2(_item: TokenStream) -> TokenStream {
803 TokenStream
804 }
805 ",
806 );
807
808 assert_eq!(def_map.exported_proc_macros.len(), 1);
809 match def_map.exported_proc_macros.values().next() {
810 Some(ProcMacroDef { kind: ProcMacroKind::CustomDerive { helpers }, .. }) => {
811 match &**helpers {
812 [attr] => assert_eq!(attr.to_string(), "helper_attr"),
813 _ => unreachable!(),
814 }
815 }
816 _ => unreachable!(),
817 }
818}