Basic support for decl macros 2.0

This commit is contained in:
Jonas Schievink 2020-12-15 18:43:19 +01:00
parent bd4c352831
commit c31c3246a8
15 changed files with 195 additions and 28 deletions

View file

@ -145,7 +145,10 @@ impl HirFileId {
let arg_tt = loc.kind.arg(db)?;
let def = loc.def.ast_id.and_then(|id| {
let def_tt = id.to_node(db).token_tree()?;
let def_tt = match id.to_node(db) {
ast::Macro::MacroRules(mac) => mac.token_tree()?,
ast::Macro::MacroDef(_) => return None,
};
Some(InFile::new(id.file_id, def_tt))
});
@ -228,7 +231,7 @@ pub struct MacroDefId {
// (which will probably require touching this code), we can instead use
// that (and also remove the hacks for resolving built-in derives).
pub krate: Option<CrateId>,
pub ast_id: Option<AstId<ast::MacroRules>>,
pub ast_id: Option<AstId<ast::Macro>>,
pub kind: MacroDefKind,
pub local_inner: bool,