Store an AstId for procedural macros

This commit is contained in:
Jonas Schievink 2021-03-18 16:11:18 +01:00
parent 3ab9b39dd4
commit c05a1a6e37
11 changed files with 47 additions and 26 deletions

View file

@ -157,7 +157,7 @@ fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<(TokenExpander,
Some(Arc::new((TokenExpander::BuiltinDerive(expander), mbe::TokenMap::default())))
}
MacroDefKind::BuiltInEager(..) => None,
MacroDefKind::ProcMacro(expander) => {
MacroDefKind::ProcMacro(expander, ..) => {
Some(Arc::new((TokenExpander::ProcMacro(expander), mbe::TokenMap::default())))
}
}
@ -269,7 +269,7 @@ fn expand_proc_macro(
};
let expander = match loc.def.kind {
MacroDefKind::ProcMacro(expander) => expander,
MacroDefKind::ProcMacro(expander, ..) => expander,
_ => unreachable!(),
};

View file

@ -209,7 +209,7 @@ fn eager_macro_recur(
MacroDefKind::Declarative(_)
| MacroDefKind::BuiltIn(..)
| MacroDefKind::BuiltInDerive(..)
| MacroDefKind::ProcMacro(_) => {
| MacroDefKind::ProcMacro(..) => {
let res = lazy_expand(db, &def, curr.with_value(child.clone()), krate);
let val = diagnostic_sink.expand_result_option(res)?;

View file

@ -182,7 +182,7 @@ impl HygieneFrame {
MacroDefKind::BuiltIn(..) => (info, Some(loc.def.krate), false),
MacroDefKind::BuiltInDerive(..) => (info, None, false),
MacroDefKind::BuiltInEager(..) => (info, None, false),
MacroDefKind::ProcMacro(_) => (info, None, false),
MacroDefKind::ProcMacro(..) => (info, None, false),
}
}
},

View file

@ -245,7 +245,7 @@ impl MacroDefId {
MacroDefKind::BuiltIn(_, id) => id,
MacroDefKind::BuiltInDerive(_, id) => id,
MacroDefKind::BuiltInEager(_, id) => id,
MacroDefKind::ProcMacro(_) => return None,
MacroDefKind::ProcMacro(..) => return None,
};
Some(*id)
}
@ -258,7 +258,7 @@ pub enum MacroDefKind {
// FIXME: maybe just Builtin and rename BuiltinFnLikeExpander to BuiltinExpander
BuiltInDerive(BuiltinDeriveExpander, AstId<ast::Macro>),
BuiltInEager(EagerExpander, AstId<ast::Macro>),
ProcMacro(ProcMacroExpander),
ProcMacro(ProcMacroExpander, AstId<ast::Fn>),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]