Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-expand/src/lib.rs')
-rw-r--r--crates/hir-expand/src/lib.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/hir-expand/src/lib.rs b/crates/hir-expand/src/lib.rs
index 9ed6c31ddd..1f1e20f49e 100644
--- a/crates/hir-expand/src/lib.rs
+++ b/crates/hir-expand/src/lib.rs
@@ -415,6 +415,24 @@ impl MacroDefId {
)
}
+ pub fn is_derive(&self) -> bool {
+ matches!(
+ self.kind,
+ MacroDefKind::BuiltInDerive(..)
+ | MacroDefKind::ProcMacro(_, ProcMacroKind::CustomDerive, _)
+ )
+ }
+
+ pub fn is_fn_like(&self) -> bool {
+ matches!(
+ self.kind,
+ MacroDefKind::BuiltIn(..)
+ | MacroDefKind::ProcMacro(_, ProcMacroKind::FuncLike, _)
+ | MacroDefKind::BuiltInEager(..)
+ | MacroDefKind::Declarative(..)
+ )
+ }
+
pub fn is_attribute_derive(&self) -> bool {
matches!(self.kind, MacroDefKind::BuiltInAttr(expander, ..) if expander.is_derive())
}