Treat macros as HIR items
This commit is contained in:
parent
ac50a53359
commit
8c62fa0575
31 changed files with 162 additions and 256 deletions
|
@ -1100,7 +1100,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
|||
let vis = self.get_visibility(child_index);
|
||||
let def_id = self.local_def_id(child_index);
|
||||
let res = Res::Def(kind, def_id);
|
||||
callback(Export { res, ident, vis, span });
|
||||
|
||||
// FIXME: Macros are currently encoded twice, once as items and once as
|
||||
// reexports. We ignore the items here and only use the reexports.
|
||||
if !matches!(kind, DefKind::Macro(..)) {
|
||||
callback(Export { res, ident, vis, span });
|
||||
}
|
||||
|
||||
// For non-re-export structs and variants add their constructors to children.
|
||||
// Re-export lists automatically contain constructors when necessary.
|
||||
match kind {
|
||||
|
|
|
@ -448,9 +448,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
krate.visit_all_item_likes(&mut self.as_deep_visitor());
|
||||
for macro_def in krate.exported_macros() {
|
||||
self.visit_macro_def(macro_def);
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_def_path_table(&mut self) {
|
||||
|
@ -1385,6 +1382,9 @@ impl EncodeContext<'a, 'tcx> {
|
|||
|
||||
EntryKind::Fn(self.lazy(data))
|
||||
}
|
||||
hir::ItemKind::Macro(ref macro_def) => {
|
||||
EntryKind::MacroDef(self.lazy(macro_def.clone()))
|
||||
}
|
||||
hir::ItemKind::Mod(ref m) => {
|
||||
return self.encode_info_for_mod(item.def_id, m);
|
||||
}
|
||||
|
@ -1539,13 +1539,6 @@ impl EncodeContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Serialize the text of exported macros
|
||||
fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef<'_>) {
|
||||
let def_id = macro_def.def_id.to_def_id();
|
||||
record!(self.tables.kind[def_id] <- EntryKind::MacroDef(self.lazy(macro_def.ast.clone())));
|
||||
self.encode_ident_span(def_id, macro_def.ident);
|
||||
}
|
||||
|
||||
fn encode_info_for_generic_param(&mut self, def_id: DefId, kind: EntryKind, encode_type: bool) {
|
||||
record!(self.tables.kind[def_id] <- kind);
|
||||
if encode_type {
|
||||
|
@ -1915,9 +1908,6 @@ impl Visitor<'tcx> for EncodeContext<'a, 'tcx> {
|
|||
intravisit::walk_generics(self, generics);
|
||||
self.encode_info_for_generics(generics);
|
||||
}
|
||||
fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef<'tcx>) {
|
||||
self.encode_info_for_macro_def(macro_def);
|
||||
}
|
||||
}
|
||||
|
||||
impl EncodeContext<'a, 'tcx> {
|
||||
|
@ -1972,6 +1962,7 @@ impl EncodeContext<'a, 'tcx> {
|
|||
hir::ItemKind::Static(..)
|
||||
| hir::ItemKind::Const(..)
|
||||
| hir::ItemKind::Fn(..)
|
||||
| hir::ItemKind::Macro(..)
|
||||
| hir::ItemKind::Mod(..)
|
||||
| hir::ItemKind::ForeignMod { .. }
|
||||
| hir::ItemKind::GlobalAsm(..)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue