diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 8ebc0c4700e..a540c4606c9 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1010,13 +1010,7 @@ fn for_each_module_child( let span = self.get_span(child_index, sess); let macro_rules = match kind { DefKind::Macro(..) => { - self.root - .tables - .macro_definition - .get(self, child_index) - .unwrap() - .decode((self, sess)) - .macro_rules + self.root.tables.macro_rules.get(self, child_index).is_some() } _ => false, }; @@ -1326,7 +1320,10 @@ fn exported_symbols( fn get_macro(self, id: DefIndex, sess: &Session) -> ast::MacroDef { match self.def_kind(id) { DefKind::Macro(_) => { - self.root.tables.macro_definition.get(self, id).unwrap().decode((self, sess)) + let macro_rules = self.root.tables.macro_rules.get(self, id).is_some(); + let body = + self.root.tables.macro_definition.get(self, id).unwrap().decode((self, sess)); + ast::MacroDef { macro_rules, body: ast::ptr::P(body) } } _ => bug!(), } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 927db8a6ab6..1288d19cb08 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1494,7 +1494,10 @@ fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item<'tcx>) { self.tables.constness.set(def_id.index, sig.header.constness); } hir::ItemKind::Macro(ref macro_def, _) => { - record!(self.tables.macro_definition[def_id] <- macro_def); + if macro_def.macro_rules { + self.tables.macro_rules.set(def_id.index, ()); + } + record!(self.tables.macro_definition[def_id] <- &*macro_def.body); } hir::ItemKind::Mod(ref m) => { return self.encode_info_for_mod(item.def_id, m); diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 04136b68134..bb5b40bcc5b 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -394,7 +394,9 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables { may_have_doc_links: Table, variant_data: Table>, assoc_container: Table, - macro_definition: Table>, + // Slot is full when macro is macro_rules. + macro_rules: Table, + macro_definition: Table>, proc_macro: Table, // Slot is full when there is a self parameter. fn_has_self_parameter: Table, diff --git a/compiler/rustc_middle/src/ty/parameterized.rs b/compiler/rustc_middle/src/ty/parameterized.rs index 504d02c1608..ca24c0d1ce3 100644 --- a/compiler/rustc_middle/src/ty/parameterized.rs +++ b/compiler/rustc_middle/src/ty/parameterized.rs @@ -64,7 +64,7 @@ impl $crate::ty::ParameterizedOverTcx for $ty { ty::adjustment::CoerceUnsizedInfo, ty::fast_reject::SimplifiedTypeGen, rustc_ast::Attribute, - rustc_ast::MacroDef, + rustc_ast::MacArgs, rustc_attr::ConstStability, rustc_attr::DefaultBodyStability, rustc_attr::Deprecation,