Rename CustomDerive
to ProcMacro
It handles fn-like macros too, and will handle attribute macros in the future
This commit is contained in:
parent
700a3d5d75
commit
9dc0afe854
@ -908,12 +908,12 @@ impl MacroDef {
|
|||||||
|
|
||||||
/// Indicate it is a proc-macro
|
/// Indicate it is a proc-macro
|
||||||
pub fn is_proc_macro(&self) -> bool {
|
pub fn is_proc_macro(&self) -> bool {
|
||||||
matches!(self.id.kind, MacroDefKind::CustomDerive(_))
|
matches!(self.id.kind, MacroDefKind::ProcMacro(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Indicate it is a derive macro
|
/// Indicate it is a derive macro
|
||||||
pub fn is_derive_macro(&self) -> bool {
|
pub fn is_derive_macro(&self) -> bool {
|
||||||
matches!(self.id.kind, MacroDefKind::CustomDerive(_) | MacroDefKind::BuiltInDerive(_))
|
matches!(self.id.kind, MacroDefKind::ProcMacro(_) | MacroDefKind::BuiltInDerive(_))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ impl DefCollector<'_> {
|
|||||||
let macro_id = MacroDefId {
|
let macro_id = MacroDefId {
|
||||||
ast_id: None,
|
ast_id: None,
|
||||||
krate: Some(krate),
|
krate: Some(krate),
|
||||||
kind: MacroDefKind::CustomDerive(expander),
|
kind: MacroDefKind::ProcMacro(expander),
|
||||||
local_inner: false,
|
local_inner: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ pub(crate) fn macro_def(
|
|||||||
Some(Arc::new((TokenExpander::BuiltinDerive(expander), mbe::TokenMap::default())))
|
Some(Arc::new((TokenExpander::BuiltinDerive(expander), mbe::TokenMap::default())))
|
||||||
}
|
}
|
||||||
MacroDefKind::BuiltInEager(_) => None,
|
MacroDefKind::BuiltInEager(_) => None,
|
||||||
MacroDefKind::CustomDerive(expander) => {
|
MacroDefKind::ProcMacro(expander) => {
|
||||||
Some(Arc::new((TokenExpander::ProcMacro(expander), mbe::TokenMap::default())))
|
Some(Arc::new((TokenExpander::ProcMacro(expander), mbe::TokenMap::default())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,7 +249,7 @@ pub(crate) fn expand_proc_macro(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let expander = match loc.def.kind {
|
let expander = match loc.def.kind {
|
||||||
MacroDefKind::CustomDerive(expander) => expander,
|
MacroDefKind::ProcMacro(expander) => expander,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ fn eager_macro_recur(
|
|||||||
MacroDefKind::Declarative
|
MacroDefKind::Declarative
|
||||||
| MacroDefKind::BuiltIn(_)
|
| MacroDefKind::BuiltIn(_)
|
||||||
| MacroDefKind::BuiltInDerive(_)
|
| MacroDefKind::BuiltInDerive(_)
|
||||||
| MacroDefKind::CustomDerive(_) => {
|
| MacroDefKind::ProcMacro(_) => {
|
||||||
let expanded = lazy_expand(db, &def, curr.with_value(child.clone()), krate)?;
|
let expanded = lazy_expand(db, &def, curr.with_value(child.clone()), krate)?;
|
||||||
// replace macro inside
|
// replace macro inside
|
||||||
eager_macro_recur(db, expanded, krate, macro_resolver)?
|
eager_macro_recur(db, expanded, krate, macro_resolver)?
|
||||||
|
@ -33,7 +33,7 @@ impl Hygiene {
|
|||||||
MacroDefKind::BuiltIn(_) => (None, false),
|
MacroDefKind::BuiltIn(_) => (None, false),
|
||||||
MacroDefKind::BuiltInDerive(_) => (None, false),
|
MacroDefKind::BuiltInDerive(_) => (None, false),
|
||||||
MacroDefKind::BuiltInEager(_) => (None, false),
|
MacroDefKind::BuiltInEager(_) => (None, false),
|
||||||
MacroDefKind::CustomDerive(_) => (None, false),
|
MacroDefKind::ProcMacro(_) => (None, false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MacroCallId::EagerMacro(_id) => (None, false),
|
MacroCallId::EagerMacro(_id) => (None, false),
|
||||||
|
@ -246,7 +246,7 @@ pub enum MacroDefKind {
|
|||||||
// FIXME: maybe just Builtin and rename BuiltinFnLikeExpander to BuiltinExpander
|
// FIXME: maybe just Builtin and rename BuiltinFnLikeExpander to BuiltinExpander
|
||||||
BuiltInDerive(BuiltinDeriveExpander),
|
BuiltInDerive(BuiltinDeriveExpander),
|
||||||
BuiltInEager(EagerExpander),
|
BuiltInEager(EagerExpander),
|
||||||
CustomDerive(ProcMacroExpander),
|
ProcMacro(ProcMacroExpander),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user