metadata: Tweak the way in which declarative macros are encoded
To make the `macro_rules` flag more readily available without decoding everything else
This commit is contained in:
parent
17b1afdbb2
commit
50568b8ee5
@ -5,6 +5,7 @@ use crate::rmeta::table::{FixedSizeEncoding, Table};
|
||||
use crate::rmeta::*;
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_attr as attr;
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
@ -1402,9 +1403,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||
tcx.arena.alloc_from_iter(self.root.exported_symbols.decode((self, tcx)))
|
||||
}
|
||||
|
||||
fn get_macro(self, id: DefIndex, sess: &Session) -> MacroDef {
|
||||
fn get_macro(self, id: DefIndex, sess: &Session) -> ast::MacroDef {
|
||||
match self.kind(id) {
|
||||
EntryKind::MacroDef(macro_def) => macro_def.decode((self, sess)),
|
||||
EntryKind::MacroDef(mac_args, macro_rules) => {
|
||||
ast::MacroDef { body: P(mac_args.decode((self, sess))), macro_rules }
|
||||
}
|
||||
_ => bug!(),
|
||||
}
|
||||
}
|
||||
|
@ -1407,7 +1407,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
EntryKind::Fn(self.lazy(data))
|
||||
}
|
||||
hir::ItemKind::Macro(ref macro_def, _) => {
|
||||
EntryKind::MacroDef(self.lazy(macro_def.clone()))
|
||||
EntryKind::MacroDef(self.lazy(&*macro_def.body), macro_def.macro_rules)
|
||||
}
|
||||
hir::ItemKind::Mod(ref m) => {
|
||||
return self.encode_info_for_mod(item.def_id, m);
|
||||
|
@ -2,7 +2,7 @@ use decoder::Metadata;
|
||||
use def_path_hash_map::DefPathHashMapRef;
|
||||
use table::{Table, TableBuilder};
|
||||
|
||||
use rustc_ast::{self as ast, MacroDef};
|
||||
use rustc_ast as ast;
|
||||
use rustc_attr as attr;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use rustc_data_structures::sync::MetadataRef;
|
||||
@ -350,7 +350,7 @@ enum EntryKind {
|
||||
Fn(Lazy<FnData>),
|
||||
ForeignFn(Lazy<FnData>),
|
||||
Mod(Lazy<[ModChild]>),
|
||||
MacroDef(Lazy<MacroDef>),
|
||||
MacroDef(Lazy<ast::MacArgs>, /*macro_rules*/ bool),
|
||||
ProcMacro(MacroKind),
|
||||
Closure,
|
||||
Generator,
|
||||
|
Loading…
x
Reference in New Issue
Block a user