Skip to content

Commit b0b46c0

Browse files
committed
Separate macro_rules and macro_definition.
1 parent c485fcc commit b0b46c0

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -1010,13 +1010,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10101010
let span = self.get_span(child_index, sess);
10111011
let macro_rules = match kind {
10121012
DefKind::Macro(..) => {
1013-
self.root
1014-
.tables
1015-
.macro_definition
1016-
.get(self, child_index)
1017-
.unwrap()
1018-
.decode((self, sess))
1019-
.macro_rules
1013+
self.root.tables.macro_rules.get(self, child_index).is_some()
10201014
}
10211015
_ => false,
10221016
};
@@ -1326,7 +1320,10 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
13261320
fn get_macro(self, id: DefIndex, sess: &Session) -> ast::MacroDef {
13271321
match self.def_kind(id) {
13281322
DefKind::Macro(_) => {
1329-
self.root.tables.macro_definition.get(self, id).unwrap().decode((self, sess))
1323+
let macro_rules = self.root.tables.macro_rules.get(self, id).is_some();
1324+
let body =
1325+
self.root.tables.macro_definition.get(self, id).unwrap().decode((self, sess));
1326+
ast::MacroDef { macro_rules, body: ast::ptr::P(body) }
13301327
}
13311328
_ => bug!(),
13321329
}

compiler/rustc_metadata/src/rmeta/encoder.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14941494
self.tables.constness.set(def_id.index, sig.header.constness);
14951495
}
14961496
hir::ItemKind::Macro(ref macro_def, _) => {
1497-
record!(self.tables.macro_definition[def_id] <- macro_def);
1497+
if macro_def.macro_rules {
1498+
self.tables.macro_rules.set(def_id.index, ());
1499+
}
1500+
record!(self.tables.macro_definition[def_id] <- &*macro_def.body);
14981501
}
14991502
hir::ItemKind::Mod(ref m) => {
15001503
return self.encode_info_for_mod(item.def_id, m);

compiler/rustc_metadata/src/rmeta/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ define_tables! {
394394
may_have_doc_links: Table<DefIndex, ()>,
395395
variant_data: Table<DefIndex, LazyValue<VariantData>>,
396396
assoc_container: Table<DefIndex, ty::AssocItemContainer>,
397-
macro_definition: Table<DefIndex, LazyValue<ast::MacroDef>>,
397+
// Slot is full when macro is macro_rules.
398+
macro_rules: Table<DefIndex, ()>,
399+
macro_definition: Table<DefIndex, LazyValue<ast::MacArgs>>,
398400
proc_macro: Table<DefIndex, MacroKind>,
399401
// Slot is full when there is a self parameter.
400402
fn_has_self_parameter: Table<DefIndex, ()>,

compiler/rustc_middle/src/ty/parameterized.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ trivially_parameterized_over_tcx! {
6464
ty::adjustment::CoerceUnsizedInfo,
6565
ty::fast_reject::SimplifiedTypeGen<DefId>,
6666
rustc_ast::Attribute,
67-
rustc_ast::MacroDef,
67+
rustc_ast::MacArgs,
6868
rustc_attr::ConstStability,
6969
rustc_attr::DefaultBodyStability,
7070
rustc_attr::Deprecation,

0 commit comments

Comments
 (0)