diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2022-01-24 15:30:54 +0800 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2022-02-24 22:55:37 +0300 |
| commit | 50568b8ee5665e637e3fe1a481723ea2ec8a6d03 (patch) | |
| tree | ae4ef91a6d55d8b113105d8f8d48f7174087da82 | |
| parent | 17b1afdbb234a1cdf5db92ec8639cbd2909ac629 (diff) | |
| download | rust-50568b8ee5665e637e3fe1a481723ea2ec8a6d03.tar.gz rust-50568b8ee5665e637e3fe1a481723ea2ec8a6d03.zip | |
metadata: Tweak the way in which declarative macros are encoded
To make the `macro_rules` flag more readily available without decoding everything else
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/encoder.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/mod.rs | 4 |
3 files changed, 8 insertions, 5 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index aaa44a68dc0..71bd449d0c1 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 85b1b31ba84..fae76f80c4b 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 da17d9d4c67..a30cc034c4a 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<FnData>), ForeignFn(Lazy<FnData>), Mod(Lazy<[ModChild]>), - MacroDef(Lazy<MacroDef>), + MacroDef(Lazy<ast::MacArgs>, /*macro_rules*/ bool), ProcMacro(MacroKind), Closure, Generator, |
