Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir_expand/src/builtin_attr_macro.rs')
-rw-r--r--crates/hir_expand/src/builtin_attr_macro.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/crates/hir_expand/src/builtin_attr_macro.rs b/crates/hir_expand/src/builtin_attr_macro.rs
index ec587daf9b..8da8c2ee4f 100644
--- a/crates/hir_expand/src/builtin_attr_macro.rs
+++ b/crates/hir_expand/src/builtin_attr_macro.rs
@@ -36,6 +36,18 @@ macro_rules! register_builtin {
};
}
+impl BuiltinAttrExpander {
+ pub fn is_derive(self) -> bool {
+ matches!(self, BuiltinAttrExpander::Derive)
+ }
+ pub fn is_test(self) -> bool {
+ matches!(self, BuiltinAttrExpander::Test)
+ }
+ pub fn is_bench(self) -> bool {
+ matches!(self, BuiltinAttrExpander::Bench)
+ }
+}
+
register_builtin! {
(bench, Bench) => dummy_attr_expand,
(cfg_accessible, CfgAccessible) => dummy_attr_expand,
@@ -46,16 +58,6 @@ register_builtin! {
(test_case, TestCase) => dummy_attr_expand
}
-pub fn is_builtin_test_or_bench_attr(makro: MacroDefId) -> bool {
- match makro.kind {
- MacroDefKind::BuiltInAttr(expander, ..) => {
- BuiltinAttrExpander::find_by_name(&name!(test)) == Some(expander)
- || BuiltinAttrExpander::find_by_name(&name!(bench)) == Some(expander)
- }
- _ => false,
- }
-}
-
pub fn find_builtin_attr(
ident: &name::Name,
krate: CrateId,