From 6489e5b7851dab447cb630958e6870cf792efa38 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 18 Mar 2021 20:04:20 +0100 Subject: Add test --- crates/hir_def/src/nameres/tests/macros.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'crates/hir_def') 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 @@ use super::*; +use crate::nameres::proc_macro::{ProcMacroDef, ProcMacroKind}; #[test] fn macro_rules_are_globally_visible() { @@ -790,3 +791,28 @@ fn proc_macro_censoring() { "#]], ); } + +#[test] +fn collects_derive_helpers() { + let def_map = compute_crate_def_map( + r" + struct TokenStream; + + #[proc_macro_derive(AnotherTrait, attributes(helper_attr))] + pub fn derive_macro_2(_item: TokenStream) -> TokenStream { + TokenStream + } + ", + ); + + assert_eq!(def_map.exported_proc_macros.len(), 1); + match def_map.exported_proc_macros.values().next() { + Some(ProcMacroDef { kind: ProcMacroKind::CustomDerive { helpers }, .. }) => { + match &**helpers { + [attr] => assert_eq!(attr.to_string(), "helper_attr"), + _ => unreachable!(), + } + } + _ => unreachable!(), + } +} -- cgit v1.2.3