diff options
| author | bors <bors@rust-lang.org> | 2022-02-24 22:29:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-02-24 22:29:14 +0000 |
| commit | 4e82f35492ea5c78e19609bf4468f0a686d9a756 (patch) | |
| tree | 23fbd4cd23c587684432375a288e303b80be8051 /compiler/rustc_metadata/src | |
| parent | 4b043faba34ccc053a4d0110634c323f6c03765e (diff) | |
| parent | 3bd163f4e8422db4c0de384b2b21bfaaecd2e5c1 (diff) | |
| download | rust-4e82f35492ea5c78e19609bf4468f0a686d9a756.tar.gz rust-4e82f35492ea5c78e19609bf4468f0a686d9a756.zip | |
Auto merge of #94333 - Dylan-DPC:rollup-7yxtywp, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - #91795 (resolve/metadata: Stop encoding macros as reexports) - #93714 (better ObligationCause for normalization errors in `can_type_implement_copy`) - #94175 (Improve `--check-cfg` implementation) - #94212 (Stop manually SIMDing in `swap_nonoverlapping`) - #94242 (properly handle fat pointers to uninhabitable types) - #94308 (Normalize main return type during mono item collection & codegen) - #94315 (update auto trait lint for `PhantomData`) - #94316 (Improve string literal unescaping) - #94327 (Avoid emitting full macro body into JSON errors) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_metadata/src')
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder.rs | 38 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/encoder.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/mod.rs | 4 |
3 files changed, 32 insertions, 14 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index aaa44a68dc0..e5e0cce198f 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; @@ -1076,6 +1077,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { res, vis: ty::Visibility::Public, span: ident.span, + macro_rules: false, }); } } @@ -1087,17 +1089,19 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { for child_index in children.decode((self, sess)) { if let Some(ident) = self.opt_item_ident(child_index, sess) { let kind = self.def_kind(child_index); - if matches!(kind, DefKind::Macro(..)) { - // FIXME: Macros are currently encoded twice, once as items and once as - // reexports. We ignore the items here and only use the reexports. - continue; - } let def_id = self.local_def_id(child_index); let res = Res::Def(kind, def_id); let vis = self.get_visibility(child_index); let span = self.get_span(child_index, sess); + let macro_rules = match kind { + DefKind::Macro(..) => match self.kind(child_index) { + EntryKind::MacroDef(_, macro_rules) => macro_rules, + _ => unreachable!(), + }, + _ => false, + }; - callback(ModChild { ident, res, vis, span }); + callback(ModChild { ident, res, vis, span, macro_rules }); // For non-re-export structs and variants add their constructors to children. // Re-export lists automatically contain constructors when necessary. @@ -1109,7 +1113,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { let ctor_res = Res::Def(DefKind::Ctor(CtorOf::Struct, ctor_kind), ctor_def_id); let vis = self.get_visibility(ctor_def_id.index); - callback(ModChild { ident, res: ctor_res, vis, span }); + callback(ModChild { + ident, + res: ctor_res, + vis, + span, + macro_rules: false, + }); } } DefKind::Variant => { @@ -1134,7 +1144,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { vis = ty::Visibility::Restricted(crate_def_id); } } - callback(ModChild { ident, res: ctor_res, vis, span }); + callback(ModChild { + ident, + res: ctor_res, + vis, + span, + macro_rules: false, + }); } _ => {} } @@ -1402,9 +1418,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 da8995df1ac..fae76f80c4b 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1406,8 +1406,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { EntryKind::Fn(self.lazy(data)) } - hir::ItemKind::Macro(ref macro_def) => { - EntryKind::MacroDef(self.lazy(macro_def.clone())) + hir::ItemKind::Macro(ref macro_def, _) => { + 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, |
