diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index aaa44a68dc0c0..71bd449d0c1cd 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -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!(), } } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 85b1b31ba84b1..fae76f80c4bde 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -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); diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index da17d9d4c6706..a30cc034c4a96 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -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), ForeignFn(Lazy), Mod(Lazy<[ModChild]>), - MacroDef(Lazy), + MacroDef(Lazy, /*macro_rules*/ bool), ProcMacro(MacroKind), Closure, Generator,