fix: Do not create fn macro calls with non-fn expanders

This commit is contained in:
Lukas Wirth 2023-07-30 12:18:19 +02:00
parent 3db437cbd6
commit df725d6b6d
2 changed files with 29 additions and 6 deletions

View file

@ -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())
}