From 8590b16d9b031014ddcda17b174645bb7ea8ebc4 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 3 Nov 2019 15:56:11 +0300 Subject: [PATCH 1/6] rustc_metadata: Move decoder/encoder/table into mod schema --- src/librustc_metadata/cstore_impl.rs | 3 +-- src/librustc_metadata/lib.rs | 3 --- src/librustc_metadata/schema.rs | 10 ++++++++-- src/librustc_metadata/{ => schema}/decoder.rs | 4 ++-- src/librustc_metadata/{ => schema}/encoder.rs | 2 +- src/librustc_metadata/{ => schema}/table.rs | 1 - 6 files changed, 12 insertions(+), 11 deletions(-) rename src/librustc_metadata/{ => schema}/decoder.rs (99%) rename src/librustc_metadata/{ => schema}/encoder.rs (99%) rename src/librustc_metadata/{ => schema}/table.rs (99%) diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index b01b99ffcfb09..2d3a6f4fa9f22 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -1,5 +1,4 @@ use crate::cstore::{self, LoadedMacro}; -use crate::encoder; use crate::link_args; use crate::native_libs; use crate::foreign_modules; @@ -524,7 +523,7 @@ impl CrateStore for cstore::CStore { } fn encode_metadata(&self, tcx: TyCtxt<'_>) -> EncodedMetadata { - encoder::encode_metadata(tcx) + schema::encode_metadata(tcx) } fn metadata_encoding_version(&self) -> &[u8] diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index 291ee23ff7262..be7925f9f529e 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -26,15 +26,12 @@ extern crate rustc_data_structures; pub mod error_codes; -mod encoder; -mod decoder; mod dependency_format; mod cstore_impl; mod foreign_modules; mod link_args; mod native_libs; mod schema; -mod table; pub mod creader; pub mod cstore; diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index f644b7264320b..89570fda68bcb 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -1,4 +1,4 @@ -use crate::table::PerDefTable; +use table::PerDefTable; use rustc::hir; use rustc::hir::def::{self, CtorKind}; @@ -13,7 +13,6 @@ use rustc::ty::{self, Ty, ReprOptions}; use rustc_target::spec::{PanicStrategy, TargetTriple}; use rustc_index::vec::IndexVec; use rustc_data_structures::svh::Svh; - use rustc_serialize::Encodable; use syntax::{ast, attr}; use syntax::edition::Edition; @@ -23,6 +22,13 @@ use syntax_pos::{self, Span}; use std::marker::PhantomData; use std::num::NonZeroUsize; +crate use decoder::Metadata; +crate use encoder::encode_metadata; + +mod decoder; +mod encoder; +mod table; + crate fn rustc_version() -> String { format!("rustc {}", option_env!("CFG_VERSION").unwrap_or("unknown version")) diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/schema/decoder.rs similarity index 99% rename from src/librustc_metadata/decoder.rs rename to src/librustc_metadata/schema/decoder.rs index 771d01a4b6a1d..33a75e909c705 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/schema/decoder.rs @@ -2,7 +2,7 @@ use crate::cstore::{self, CrateMetadata, MetadataBlob}; use crate::schema::*; -use crate::table::{FixedSizeEncoding, PerDefTable}; +use crate::schema::table::{FixedSizeEncoding, PerDefTable}; use rustc_index::vec::IndexVec; use rustc_data_structures::sync::Lrc; @@ -1358,7 +1358,7 @@ impl<'a, 'tcx> CrateMetadata { /// Get the `DepNodeIndex` corresponding this crate. The result of this /// method is cached in the `dep_node_index` field. - pub(super) fn get_crate_dep_node_index(&self, tcx: TyCtxt<'tcx>) -> DepNodeIndex { + crate fn get_crate_dep_node_index(&self, tcx: TyCtxt<'tcx>) -> DepNodeIndex { let mut dep_node_index = self.dep_node_index.load(); if unlikely!(dep_node_index == DepNodeIndex::INVALID) { diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/schema/encoder.rs similarity index 99% rename from src/librustc_metadata/encoder.rs rename to src/librustc_metadata/schema/encoder.rs index 618d342f6fe75..2119ab9c2823e 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/schema/encoder.rs @@ -1,5 +1,5 @@ use crate::schema::*; -use crate::table::{FixedSizeEncoding, PerDefTable}; +use crate::schema::table::{FixedSizeEncoding, PerDefTable}; use rustc::middle::cstore::{LinkagePreference, NativeLibrary, EncodedMetadata, ForeignModule}; diff --git a/src/librustc_metadata/table.rs b/src/librustc_metadata/schema/table.rs similarity index 99% rename from src/librustc_metadata/table.rs rename to src/librustc_metadata/schema/table.rs index e164c28c953bc..3c2680c968c85 100644 --- a/src/librustc_metadata/table.rs +++ b/src/librustc_metadata/schema/table.rs @@ -1,4 +1,3 @@ -use crate::decoder::Metadata; use crate::schema::*; use rustc::hir::def_id::{DefId, DefIndex}; From 8e1ae56bc612a888bbd0336255bdb431249b8c74 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 3 Nov 2019 17:33:27 +0300 Subject: [PATCH 2/6] rustc_metadata: Privatize everything in schema and schema/table --- src/librustc_metadata/schema.rs | 144 +++++++++++++------------- src/librustc_metadata/schema/table.rs | 18 ++-- 2 files changed, 80 insertions(+), 82 deletions(-) diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index 89570fda68bcb..dcee19be432b9 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -1,3 +1,4 @@ +use decoder::Metadata; use table::PerDefTable; use rustc::hir; @@ -22,7 +23,6 @@ use syntax_pos::{self, Span}; use std::marker::PhantomData; use std::num::NonZeroUsize; -crate use decoder::Metadata; crate use encoder::encode_metadata; mod decoder; @@ -110,13 +110,13 @@ crate struct Lazy::Meta> where T: ?Sized + LazyMeta, Meta: 'static + Copy, { - pub position: NonZeroUsize, - pub meta: Meta, + position: NonZeroUsize, + meta: Meta, _marker: PhantomData, } impl Lazy { - crate fn from_position_and_meta(position: NonZeroUsize, meta: T::Meta) -> Lazy { + fn from_position_and_meta(position: NonZeroUsize, meta: T::Meta) -> Lazy { Lazy { position, meta, @@ -126,13 +126,13 @@ impl Lazy { } impl Lazy { - crate fn from_position(position: NonZeroUsize) -> Lazy { + fn from_position(position: NonZeroUsize) -> Lazy { Lazy::from_position_and_meta(position, ()) } } impl Lazy<[T]> { - crate fn empty() -> Lazy<[T]> { + fn empty() -> Lazy<[T]> { Lazy::from_position_and_meta(NonZeroUsize::new(1).unwrap(), 0) } } @@ -149,7 +149,7 @@ impl rustc_serialize::UseSpecializedDecodable for Lazy /// Encoding / decoding state for `Lazy`. #[derive(Copy, Clone, PartialEq, Eq, Debug)] -crate enum LazyState { +enum LazyState { /// Outside of a metadata node. NoNode, @@ -187,23 +187,23 @@ crate struct CrateRoot<'tcx> { pub has_default_lib_allocator: bool, pub plugin_registrar_fn: Option, pub proc_macro_decls_static: Option, - pub proc_macro_stability: Option, + proc_macro_stability: Option, pub crate_deps: Lazy<[CrateDep]>, - pub dylib_dependency_formats: Lazy<[Option]>, - pub lib_features: Lazy<[(Symbol, Option)]>, - pub lang_items: Lazy<[(DefIndex, usize)]>, - pub lang_items_missing: Lazy<[lang_items::LangItem]>, - pub diagnostic_items: Lazy<[(Symbol, DefIndex)]>, - pub native_libraries: Lazy<[NativeLibrary]>, - pub foreign_modules: Lazy<[ForeignModule]>, - pub source_map: Lazy<[syntax_pos::SourceFile]>, + dylib_dependency_formats: Lazy<[Option]>, + lib_features: Lazy<[(Symbol, Option)]>, + lang_items: Lazy<[(DefIndex, usize)]>, + lang_items_missing: Lazy<[lang_items::LangItem]>, + diagnostic_items: Lazy<[(Symbol, DefIndex)]>, + native_libraries: Lazy<[NativeLibrary]>, + foreign_modules: Lazy<[ForeignModule]>, + source_map: Lazy<[syntax_pos::SourceFile]>, pub def_path_table: Lazy, pub impls: Lazy<[TraitImpls]>, - pub exported_symbols: Lazy!([(ExportedSymbol<'tcx>, SymbolExportLevel)]), + exported_symbols: Lazy!([(ExportedSymbol<'tcx>, SymbolExportLevel)]), pub interpret_alloc_index: Lazy<[u32]>, - pub per_def: LazyPerDefTables<'tcx>, + per_def: LazyPerDefTables<'tcx>, /// The DefIndex's of any proc macros delcared by /// this crate @@ -236,35 +236,33 @@ crate struct TraitImpls { #[derive(RustcEncodable, RustcDecodable)] crate struct LazyPerDefTables<'tcx> { - pub kind: Lazy!(PerDefTable)>), - pub visibility: Lazy!(PerDefTable>), - pub span: Lazy!(PerDefTable>), - pub attributes: Lazy!(PerDefTable>), - pub children: Lazy!(PerDefTable>), - pub stability: Lazy!(PerDefTable>), - pub deprecation: Lazy!(PerDefTable>), - - pub ty: Lazy!(PerDefTable)>), - pub fn_sig: Lazy!(PerDefTable)>), - pub impl_trait_ref: Lazy!(PerDefTable)>), - pub inherent_impls: Lazy!(PerDefTable>), - pub variances: Lazy!(PerDefTable>), - pub generics: Lazy!(PerDefTable>), - pub explicit_predicates: Lazy!(PerDefTable)>), + kind: Lazy!(PerDefTable)>), + visibility: Lazy!(PerDefTable>), + span: Lazy!(PerDefTable>), + attributes: Lazy!(PerDefTable>), + children: Lazy!(PerDefTable>), + stability: Lazy!(PerDefTable>), + deprecation: Lazy!(PerDefTable>), + ty: Lazy!(PerDefTable)>), + fn_sig: Lazy!(PerDefTable)>), + impl_trait_ref: Lazy!(PerDefTable)>), + inherent_impls: Lazy!(PerDefTable>), + variances: Lazy!(PerDefTable>), + generics: Lazy!(PerDefTable>), + explicit_predicates: Lazy!(PerDefTable)>), // FIXME(eddyb) this would ideally be `Lazy<[...]>` but `ty::Predicate` // doesn't handle shorthands in its own (de)serialization impls, // as it's an `enum` for which we want to derive (de)serialization, // so the `ty::codec` APIs handle the whole `&'tcx [...]` at once. // Also, as an optimization, a missing entry indicates an empty `&[]`. - pub inferred_outlives: Lazy!(PerDefTable, Span)])>), - pub super_predicates: Lazy!(PerDefTable)>), - - pub mir: Lazy!(PerDefTable)>), - pub promoted_mir: Lazy!(PerDefTable>)>), + inferred_outlives: Lazy!(PerDefTable, Span)])>), + super_predicates: Lazy!(PerDefTable)>), + mir: Lazy!(PerDefTable)>), + promoted_mir: Lazy!(PerDefTable>)>), } #[derive(Copy, Clone, RustcEncodable, RustcDecodable)] -crate enum EntryKind<'tcx> { +enum EntryKind<'tcx> { Const(ConstQualif, Lazy), ImmStatic, MutStatic, @@ -299,18 +297,18 @@ crate enum EntryKind<'tcx> { /// Additional data for EntryKind::Const and EntryKind::AssocConst #[derive(Clone, Copy, RustcEncodable, RustcDecodable)] -crate struct ConstQualif { - pub mir: u8, +struct ConstQualif { + mir: u8, } /// Contains a constant which has been rendered to a String. /// Used by rustdoc. #[derive(RustcEncodable, RustcDecodable)] -crate struct RenderedConst(pub String); +struct RenderedConst(String); #[derive(RustcEncodable, RustcDecodable)] -crate struct ModData { - pub reexports: Lazy<[def::Export]>, +struct ModData { + reexports: Lazy<[def::Export]>, } #[derive(RustcEncodable, RustcDecodable)] @@ -320,37 +318,37 @@ crate struct MacroDef { } #[derive(RustcEncodable, RustcDecodable)] -crate struct FnData { - pub asyncness: hir::IsAsync, - pub constness: hir::Constness, - pub param_names: Lazy<[ast::Name]>, +struct FnData { + asyncness: hir::IsAsync, + constness: hir::Constness, + param_names: Lazy<[ast::Name]>, } #[derive(RustcEncodable, RustcDecodable)] -crate struct VariantData { - pub ctor_kind: CtorKind, - pub discr: ty::VariantDiscr, +struct VariantData { + ctor_kind: CtorKind, + discr: ty::VariantDiscr, /// If this is unit or tuple-variant/struct, then this is the index of the ctor id. - pub ctor: Option, + ctor: Option, } #[derive(RustcEncodable, RustcDecodable)] -crate struct TraitData { - pub unsafety: hir::Unsafety, - pub paren_sugar: bool, - pub has_auto_impl: bool, - pub is_marker: bool, +struct TraitData { + unsafety: hir::Unsafety, + paren_sugar: bool, + has_auto_impl: bool, + is_marker: bool, } #[derive(RustcEncodable, RustcDecodable)] -crate struct ImplData { - pub polarity: ty::ImplPolarity, - pub defaultness: hir::Defaultness, - pub parent_impl: Option, +struct ImplData { + polarity: ty::ImplPolarity, + defaultness: hir::Defaultness, + parent_impl: Option, /// This is `Some` only for impls of `CoerceUnsized`. // FIXME(eddyb) perhaps compute this on the fly if cheap enough? - pub coerce_unsized_info: Option, + coerce_unsized_info: Option, } @@ -358,7 +356,7 @@ crate struct ImplData { /// is a trait or an impl and whether, in a trait, it has /// a default, or an in impl, whether it's marked "default". #[derive(Copy, Clone, RustcEncodable, RustcDecodable)] -crate enum AssocContainer { +enum AssocContainer { TraitRequired, TraitWithDefault, ImplDefault, @@ -366,7 +364,7 @@ crate enum AssocContainer { } impl AssocContainer { - crate fn with_def_id(&self, def_id: DefId) -> ty::AssocItemContainer { + fn with_def_id(&self, def_id: DefId) -> ty::AssocItemContainer { match *self { AssocContainer::TraitRequired | AssocContainer::TraitWithDefault => ty::TraitContainer(def_id), @@ -376,7 +374,7 @@ impl AssocContainer { } } - crate fn defaultness(&self) -> hir::Defaultness { + fn defaultness(&self) -> hir::Defaultness { match *self { AssocContainer::TraitRequired => hir::Defaultness::Default { has_value: false, @@ -393,17 +391,17 @@ impl AssocContainer { } #[derive(RustcEncodable, RustcDecodable)] -crate struct MethodData { - pub fn_data: FnData, - pub container: AssocContainer, - pub has_self: bool, +struct MethodData { + fn_data: FnData, + container: AssocContainer, + has_self: bool, } #[derive(RustcEncodable, RustcDecodable)] -crate struct GeneratorData<'tcx> { - pub layout: mir::GeneratorLayout<'tcx>, +struct GeneratorData<'tcx> { + layout: mir::GeneratorLayout<'tcx>, } // Tags used for encoding Spans: -crate const TAG_VALID_SPAN: u8 = 0; -crate const TAG_INVALID_SPAN: u8 = 1; +const TAG_VALID_SPAN: u8 = 0; +const TAG_INVALID_SPAN: u8 = 1; diff --git a/src/librustc_metadata/schema/table.rs b/src/librustc_metadata/schema/table.rs index 3c2680c968c85..cc65ab8a8ff55 100644 --- a/src/librustc_metadata/schema/table.rs +++ b/src/librustc_metadata/schema/table.rs @@ -11,7 +11,7 @@ use log::debug; /// Used mainly for Lazy positions and lengths. /// Unchecked invariant: `Self::default()` should encode as `[0; BYTE_LEN]`, /// but this has no impact on safety. -crate trait FixedSizeEncoding: Default { +pub(super) trait FixedSizeEncoding: Default { const BYTE_LEN: usize; // FIXME(eddyb) convert to and from `[u8; Self::BYTE_LEN]` instead, @@ -125,7 +125,7 @@ impl FixedSizeEncoding for Option> { // FIXME(eddyb) replace `Vec` with `[_]` here, such that `Box>` would be used // when building it, and `Lazy>` or `&Table` when reading it. // (not sure if that is possible given that the `Vec` is being resized now) -crate struct Table where Option: FixedSizeEncoding { +pub(super) struct Table where Option: FixedSizeEncoding { // FIXME(eddyb) store `[u8; >::BYTE_LEN]` instead of `u8` in `Vec`, // once that starts being allowed by the compiler (i.e. lazy normalization). bytes: Vec, @@ -142,7 +142,7 @@ impl Default for Table where Option: FixedSizeEncoding { } impl Table where Option: FixedSizeEncoding { - crate fn set(&mut self, i: usize, value: T) { + fn set(&mut self, i: usize, value: T) { // FIXME(eddyb) investigate more compact encodings for sparse tables. // On the PR @michaelwoerister mentioned: // > Space requirements could perhaps be optimized by using the HAMT `popcnt` @@ -156,7 +156,7 @@ impl Table where Option: FixedSizeEncoding { Some(value).write_to_bytes_at(&mut self.bytes, i); } - crate fn encode(&self, buf: &mut Encoder) -> Lazy { + fn encode(&self, buf: &mut Encoder) -> Lazy { let pos = buf.position(); buf.emit_raw_bytes(&self.bytes); Lazy::from_position_and_meta( @@ -177,7 +177,7 @@ impl LazyMeta for Table where Option: FixedSizeEncoding { impl Lazy> where Option: FixedSizeEncoding { /// Given the metadata, extract out the value at a particular index (if any). #[inline(never)] - crate fn get<'a, 'tcx, M: Metadata<'a, 'tcx>>( + fn get<'a, 'tcx, M: Metadata<'a, 'tcx>>( &self, metadata: M, i: usize, @@ -193,7 +193,7 @@ impl Lazy> where Option: FixedSizeEncoding { /// Like a `Table` but using `DefIndex` instead of `usize` as keys. // FIXME(eddyb) replace by making `Table` behave like `IndexVec`, // and by using `newtype_index!` to define `DefIndex`. -crate struct PerDefTable(Table) where Option: FixedSizeEncoding; +pub(super) struct PerDefTable(Table) where Option: FixedSizeEncoding; impl Default for PerDefTable where Option: FixedSizeEncoding { fn default() -> Self { @@ -202,12 +202,12 @@ impl Default for PerDefTable where Option: FixedSizeEncoding { } impl PerDefTable where Option: FixedSizeEncoding { - crate fn set(&mut self, def_id: DefId, value: T) { + pub(super) fn set(&mut self, def_id: DefId, value: T) { assert!(def_id.is_local()); self.0.set(def_id.index.index(), value); } - crate fn encode(&self, buf: &mut Encoder) -> Lazy { + pub(super) fn encode(&self, buf: &mut Encoder) -> Lazy { let lazy = self.0.encode(buf); Lazy::from_position_and_meta(lazy.position, lazy.meta) } @@ -228,7 +228,7 @@ impl Lazy> where Option: FixedSizeEncoding { /// Given the metadata, extract out the value at a particular DefIndex (if any). #[inline(never)] - crate fn get<'a, 'tcx, M: Metadata<'a, 'tcx>>( + pub(super) fn get<'a, 'tcx, M: Metadata<'a, 'tcx>>( &self, metadata: M, def_index: DefIndex, From 0c9d4246b0826430d287936f9041a13ab5581710 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 3 Nov 2019 17:36:16 +0300 Subject: [PATCH 3/6] rustc_metadata: Move cstore_impl into mod decoder --- src/librustc_metadata/cstore.rs | 2 +- src/librustc_metadata/lib.rs | 1 - src/librustc_metadata/schema.rs | 1 + src/librustc_metadata/schema/decoder.rs | 4 ++++ src/librustc_metadata/{ => schema/decoder}/cstore_impl.rs | 0 5 files changed, 6 insertions(+), 2 deletions(-) rename src/librustc_metadata/{ => schema/decoder}/cstore_impl.rs (100%) diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index b7596d2018f7e..656ece79add92 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -17,7 +17,7 @@ use syntax_expand::base::SyntaxExtension; use syntax_pos; use proc_macro::bridge::client::ProcMacro; -pub use crate::cstore_impl::{provide, provide_extern}; +pub use crate::schema::{provide, provide_extern}; // A map from external crate numbers (as decoded from some crate file) to // local crate numbers (as generated during this session). Each external diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index be7925f9f529e..516f9feb94573 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -27,7 +27,6 @@ extern crate rustc_data_structures; pub mod error_codes; mod dependency_format; -mod cstore_impl; mod foreign_modules; mod link_args; mod native_libs; diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index dcee19be432b9..e7b56fed50a5f 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -23,6 +23,7 @@ use syntax_pos::{self, Span}; use std::marker::PhantomData; use std::num::NonZeroUsize; +pub use decoder::{provide, provide_extern}; crate use encoder::encode_metadata; mod decoder; diff --git a/src/librustc_metadata/schema/decoder.rs b/src/librustc_metadata/schema/decoder.rs index 33a75e909c705..2264cd3804e0d 100644 --- a/src/librustc_metadata/schema/decoder.rs +++ b/src/librustc_metadata/schema/decoder.rs @@ -40,6 +40,10 @@ use syntax_pos::symbol::{Symbol, sym}; use log::debug; use proc_macro::bridge::client::ProcMacro; +pub use cstore_impl::{provide, provide_extern}; + +mod cstore_impl; + crate struct DecodeContext<'a, 'tcx> { opaque: opaque::Decoder<'a>, cdata: Option<&'a CrateMetadata>, diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/schema/decoder/cstore_impl.rs similarity index 100% rename from src/librustc_metadata/cstore_impl.rs rename to src/librustc_metadata/schema/decoder/cstore_impl.rs From 166d5f8b2fa853e3fa14a719c13d59b7b7160237 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 3 Nov 2019 17:13:07 +0300 Subject: [PATCH 4/6] rustc_metadata: Privatize everything in decoder --- src/librustc_metadata/schema/decoder.rs | 108 ++++++++++++------------ 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/src/librustc_metadata/schema/decoder.rs b/src/librustc_metadata/schema/decoder.rs index 2264cd3804e0d..0d113cecff561 100644 --- a/src/librustc_metadata/schema/decoder.rs +++ b/src/librustc_metadata/schema/decoder.rs @@ -468,7 +468,7 @@ impl<'tcx> EntryKind<'tcx> { } impl<'a, 'tcx> CrateMetadata { - crate fn is_proc_macro_crate(&self) -> bool { + fn is_proc_macro_crate(&self) -> bool { self.root.proc_macro_decls_static.is_some() } @@ -511,7 +511,7 @@ impl<'a, 'tcx> CrateMetadata { &self.raw_proc_macros.unwrap()[pos] } - crate fn item_name(&self, item_index: DefIndex) -> Symbol { + fn item_name(&self, item_index: DefIndex) -> Symbol { if !self.is_proc_macro(item_index) { self.def_key(item_index) .disambiguated_data @@ -523,7 +523,7 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn def_kind(&self, index: DefIndex) -> Option { + fn def_kind(&self, index: DefIndex) -> Option { if !self.is_proc_macro(index) { self.kind(index).def_kind() } else { @@ -533,11 +533,11 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn get_span(&self, index: DefIndex, sess: &Session) -> Span { + fn get_span(&self, index: DefIndex, sess: &Session) -> Span { self.root.per_def.span.get(self, index).unwrap().decode((self, sess)) } - crate fn load_proc_macro(&self, id: DefIndex, sess: &Session) -> SyntaxExtension { + fn load_proc_macro(&self, id: DefIndex, sess: &Session) -> SyntaxExtension { let (name, kind, helper_attrs) = match *self.raw_proc_macro(id) { ProcMacro::CustomDerive { trait_name, attributes, client } => { let helper_attrs = @@ -567,7 +567,7 @@ impl<'a, 'tcx> CrateMetadata { ) } - crate fn get_trait_def(&self, item_id: DefIndex, sess: &Session) -> ty::TraitDef { + fn get_trait_def(&self, item_id: DefIndex, sess: &Session) -> ty::TraitDef { match self.kind(item_id) { EntryKind::Trait(data) => { let data = data.decode((self, sess)); @@ -637,7 +637,7 @@ impl<'a, 'tcx> CrateMetadata { ) } - crate fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> &'tcx ty::AdtDef { + fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> &'tcx ty::AdtDef { let kind = self.kind(item_id); let did = self.local_def_id(item_id); @@ -662,7 +662,7 @@ impl<'a, 'tcx> CrateMetadata { tcx.alloc_adt_def(did, adt_kind, variants, repr) } - crate fn get_explicit_predicates( + fn get_explicit_predicates( &self, item_id: DefIndex, tcx: TyCtxt<'tcx>, @@ -670,7 +670,7 @@ impl<'a, 'tcx> CrateMetadata { self.root.per_def.explicit_predicates.get(self, item_id).unwrap().decode((self, tcx)) } - crate fn get_inferred_outlives( + fn get_inferred_outlives( &self, item_id: DefIndex, tcx: TyCtxt<'tcx>, @@ -680,7 +680,7 @@ impl<'a, 'tcx> CrateMetadata { }).unwrap_or_default() } - crate fn get_super_predicates( + fn get_super_predicates( &self, item_id: DefIndex, tcx: TyCtxt<'tcx>, @@ -688,28 +688,28 @@ impl<'a, 'tcx> CrateMetadata { self.root.per_def.super_predicates.get(self, item_id).unwrap().decode((self, tcx)) } - crate fn get_generics(&self, item_id: DefIndex, sess: &Session) -> ty::Generics { + fn get_generics(&self, item_id: DefIndex, sess: &Session) -> ty::Generics { self.root.per_def.generics.get(self, item_id).unwrap().decode((self, sess)) } - crate fn get_type(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { + fn get_type(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { self.root.per_def.ty.get(self, id).unwrap().decode((self, tcx)) } - crate fn get_stability(&self, id: DefIndex) -> Option { + fn get_stability(&self, id: DefIndex) -> Option { match self.is_proc_macro(id) { true => self.root.proc_macro_stability.clone(), false => self.root.per_def.stability.get(self, id).map(|stab| stab.decode(self)), } } - crate fn get_deprecation(&self, id: DefIndex) -> Option { + fn get_deprecation(&self, id: DefIndex) -> Option { self.root.per_def.deprecation.get(self, id) .filter(|_| !self.is_proc_macro(id)) .map(|depr| depr.decode(self)) } - crate fn get_visibility(&self, id: DefIndex) -> ty::Visibility { + fn get_visibility(&self, id: DefIndex) -> ty::Visibility { match self.is_proc_macro(id) { true => ty::Visibility::Public, false => self.root.per_def.visibility.get(self, id).unwrap().decode(self), @@ -723,31 +723,31 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn get_parent_impl(&self, id: DefIndex) -> Option { + fn get_parent_impl(&self, id: DefIndex) -> Option { self.get_impl_data(id).parent_impl } - crate fn get_impl_polarity(&self, id: DefIndex) -> ty::ImplPolarity { + fn get_impl_polarity(&self, id: DefIndex) -> ty::ImplPolarity { self.get_impl_data(id).polarity } - crate fn get_impl_defaultness(&self, id: DefIndex) -> hir::Defaultness { + fn get_impl_defaultness(&self, id: DefIndex) -> hir::Defaultness { self.get_impl_data(id).defaultness } - crate fn get_coerce_unsized_info( + fn get_coerce_unsized_info( &self, id: DefIndex, ) -> Option { self.get_impl_data(id).coerce_unsized_info } - crate fn get_impl_trait(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Option> { + fn get_impl_trait(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Option> { self.root.per_def.impl_trait_ref.get(self, id).map(|tr| tr.decode((self, tcx))) } /// Iterates over all the stability attributes in the given crate. - crate fn get_lib_features(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(ast::Name, Option)] { + fn get_lib_features(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(ast::Name, Option)] { // FIXME: For a proc macro crate, not sure whether we should return the "host" // features or an empty Vec. Both don't cause ICEs. tcx.arena.alloc_from_iter(self.root @@ -756,7 +756,7 @@ impl<'a, 'tcx> CrateMetadata { } /// Iterates over the language items in the given crate. - crate fn get_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, usize)] { + fn get_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, usize)] { if self.is_proc_macro_crate() { // Proc macro crates do not export any lang-items to the target. &[] @@ -769,7 +769,7 @@ impl<'a, 'tcx> CrateMetadata { } /// Iterates over the diagnostic items in the given crate. - crate fn get_diagnostic_items( + fn get_diagnostic_items( &self, tcx: TyCtxt<'tcx>, ) -> &'tcx FxHashMap { @@ -786,7 +786,7 @@ impl<'a, 'tcx> CrateMetadata { } /// Iterates over each child of the given item. - crate fn each_child_of_item(&self, id: DefIndex, mut callback: F, sess: &Session) + fn each_child_of_item(&self, id: DefIndex, mut callback: F, sess: &Session) where F: FnMut(def::Export) { if let Some(proc_macros_ids) = self.root.proc_macro_data.map(|d| d.decode(self)) { @@ -925,12 +925,12 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn is_item_mir_available(&self, id: DefIndex) -> bool { + fn is_item_mir_available(&self, id: DefIndex) -> bool { !self.is_proc_macro(id) && self.root.per_def.mir.get(self, id).is_some() } - crate fn get_optimized_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Body<'tcx> { + fn get_optimized_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Body<'tcx> { self.root.per_def.mir.get(self, id) .filter(|_| !self.is_proc_macro(id)) .unwrap_or_else(|| { @@ -939,7 +939,7 @@ impl<'a, 'tcx> CrateMetadata { .decode((self, tcx)) } - crate fn get_promoted_mir( + fn get_promoted_mir( &self, tcx: TyCtxt<'tcx>, id: DefIndex, @@ -952,7 +952,7 @@ impl<'a, 'tcx> CrateMetadata { .decode((self, tcx)) } - crate fn mir_const_qualif(&self, id: DefIndex) -> u8 { + fn mir_const_qualif(&self, id: DefIndex) -> u8 { match self.kind(id) { EntryKind::Const(qualif, _) | EntryKind::AssocConst(AssocContainer::ImplDefault, qualif, _) | @@ -963,7 +963,7 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn get_associated_item(&self, id: DefIndex) -> ty::AssocItem { + fn get_associated_item(&self, id: DefIndex) -> ty::AssocItem { let def_key = self.def_key(id); let parent = self.local_def_id(def_key.parent.unwrap()); let name = def_key.disambiguated_data.data.get_opt_name().unwrap(); @@ -996,12 +996,12 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn get_item_variances(&self, id: DefIndex) -> Vec { + fn get_item_variances(&self, id: DefIndex) -> Vec { self.root.per_def.variances.get(self, id).unwrap_or(Lazy::empty()) .decode(self).collect() } - crate fn get_ctor_kind(&self, node_id: DefIndex) -> CtorKind { + fn get_ctor_kind(&self, node_id: DefIndex) -> CtorKind { match self.kind(node_id) { EntryKind::Struct(data, _) | EntryKind::Union(data, _) | @@ -1010,7 +1010,7 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn get_ctor_def_id(&self, node_id: DefIndex) -> Option { + fn get_ctor_def_id(&self, node_id: DefIndex) -> Option { match self.kind(node_id) { EntryKind::Struct(data, _) => { data.decode(self).ctor.map(|index| self.local_def_id(index)) @@ -1022,7 +1022,7 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Lrc<[ast::Attribute]> { + fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Lrc<[ast::Attribute]> { // The attributes for a tuple struct/variant are attached to the definition, not the ctor; // we assume that someone passing in a tuple struct ctor is actually wanting to // look at the definition @@ -1038,7 +1038,7 @@ impl<'a, 'tcx> CrateMetadata { .collect::>()) } - crate fn get_struct_field_names( + fn get_struct_field_names( &self, id: DefIndex, sess: &Session, @@ -1064,7 +1064,7 @@ impl<'a, 'tcx> CrateMetadata { None } - crate fn get_inherent_implementations_for_type( + fn get_inherent_implementations_for_type( &self, tcx: TyCtxt<'tcx>, id: DefIndex, @@ -1076,7 +1076,7 @@ impl<'a, 'tcx> CrateMetadata { ) } - crate fn get_implementations_for_trait( + fn get_implementations_for_trait( &self, tcx: TyCtxt<'tcx>, filter: Option, @@ -1107,7 +1107,7 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn get_trait_of_item(&self, id: DefIndex) -> Option { + fn get_trait_of_item(&self, id: DefIndex) -> Option { let def_key = self.def_key(id); match def_key.disambiguated_data.data { DefPathData::TypeNs(..) | DefPathData::ValueNs(..) => (), @@ -1124,7 +1124,7 @@ impl<'a, 'tcx> CrateMetadata { } - crate fn get_native_libraries(&self, sess: &Session) -> Vec { + fn get_native_libraries(&self, sess: &Session) -> Vec { if self.is_proc_macro_crate() { // Proc macro crates do not have any *target* native libraries. vec![] @@ -1133,7 +1133,7 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn get_foreign_modules(&self, tcx: TyCtxt<'tcx>) -> &'tcx [ForeignModule] { + fn get_foreign_modules(&self, tcx: TyCtxt<'tcx>) -> &'tcx [ForeignModule] { if self.is_proc_macro_crate() { // Proc macro crates do not have any *target* foreign modules. &[] @@ -1142,7 +1142,7 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn get_dylib_dependency_formats( + fn get_dylib_dependency_formats( &self, tcx: TyCtxt<'tcx>, ) -> &'tcx [(CrateNum, LinkagePreference)] { @@ -1156,7 +1156,7 @@ impl<'a, 'tcx> CrateMetadata { })) } - crate fn get_missing_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [lang_items::LangItem] { + fn get_missing_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [lang_items::LangItem] { if self.is_proc_macro_crate() { // Proc macro crates do not depend on any target weak lang-items. &[] @@ -1167,7 +1167,7 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn get_fn_param_names(&self, id: DefIndex) -> Vec { + fn get_fn_param_names(&self, id: DefIndex) -> Vec { let param_names = match self.kind(id) { EntryKind::Fn(data) | EntryKind::ForeignFn(data) => data.decode(self).param_names, @@ -1177,7 +1177,7 @@ impl<'a, 'tcx> CrateMetadata { param_names.decode(self).collect() } - crate fn exported_symbols( + fn exported_symbols( &self, tcx: TyCtxt<'tcx>, ) -> Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)> { @@ -1190,7 +1190,7 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn get_rendered_const(&self, id: DefIndex) -> String { + fn get_rendered_const(&self, id: DefIndex) -> String { match self.kind(id) { EntryKind::Const(_, data) | EntryKind::AssocConst(_, _, data) => data.decode(self).0, @@ -1198,14 +1198,14 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn get_macro(&self, id: DefIndex) -> MacroDef { + fn get_macro(&self, id: DefIndex) -> MacroDef { match self.kind(id) { EntryKind::MacroDef(macro_def) => macro_def.decode(self), _ => bug!(), } } - crate fn is_const_fn_raw(&self, id: DefIndex) -> bool { + fn is_const_fn_raw(&self, id: DefIndex) -> bool { let constness = match self.kind(id) { EntryKind::Method(data) => data.decode(self).fn_data.constness, EntryKind::Fn(data) => data.decode(self).constness, @@ -1215,7 +1215,7 @@ impl<'a, 'tcx> CrateMetadata { constness == hir::Constness::Const } - crate fn asyncness(&self, id: DefIndex) -> hir::IsAsync { + fn asyncness(&self, id: DefIndex) -> hir::IsAsync { match self.kind(id) { EntryKind::Fn(data) => data.decode(self).asyncness, EntryKind::Method(data) => data.decode(self).fn_data.asyncness, @@ -1224,7 +1224,7 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn is_foreign_item(&self, id: DefIndex) -> bool { + fn is_foreign_item(&self, id: DefIndex) -> bool { match self.kind(id) { EntryKind::ForeignImmStatic | EntryKind::ForeignMutStatic | @@ -1233,7 +1233,7 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn static_mutability(&self, id: DefIndex) -> Option { + fn static_mutability(&self, id: DefIndex) -> Option { match self.kind(id) { EntryKind::ImmStatic | EntryKind::ForeignImmStatic => Some(hir::MutImmutable), @@ -1243,12 +1243,12 @@ impl<'a, 'tcx> CrateMetadata { } } - crate fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> { + fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> { self.root.per_def.fn_sig.get(self, id).unwrap().decode((self, tcx)) } #[inline] - crate fn def_key(&self, index: DefIndex) -> DefKey { + fn def_key(&self, index: DefIndex) -> DefKey { let mut key = self.def_path_table.def_key(index); if self.is_proc_macro(index) { let name = self.raw_proc_macro(index).name(); @@ -1258,13 +1258,13 @@ impl<'a, 'tcx> CrateMetadata { } // Returns the path leading to the thing with this `id`. - crate fn def_path(&self, id: DefIndex) -> DefPath { + fn def_path(&self, id: DefIndex) -> DefPath { debug!("def_path(cnum={:?}, id={:?})", self.cnum, id); DefPath::make(self.cnum, id, |parent| self.def_key(parent)) } #[inline] - crate fn def_path_hash(&self, index: DefIndex) -> DefPathHash { + fn def_path_hash(&self, index: DefIndex) -> DefPathHash { self.def_path_table.def_path_hash(index) } @@ -1362,7 +1362,7 @@ impl<'a, 'tcx> CrateMetadata { /// Get the `DepNodeIndex` corresponding this crate. The result of this /// method is cached in the `dep_node_index` field. - crate fn get_crate_dep_node_index(&self, tcx: TyCtxt<'tcx>) -> DepNodeIndex { + fn get_crate_dep_node_index(&self, tcx: TyCtxt<'tcx>) -> DepNodeIndex { let mut dep_node_index = self.dep_node_index.load(); if unlikely!(dep_node_index == DepNodeIndex::INVALID) { From 2b75147451ffe8654963b3399df40d40c6ed0ff2 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 3 Nov 2019 18:27:24 +0300 Subject: [PATCH 5/6] rustc_metadata: Privatize more entities --- src/librustc_metadata/schema.rs | 23 +++++++++---------- .../schema/decoder/cstore_impl.rs | 4 ++-- src/librustc_metadata/schema/encoder.rs | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index e7b56fed50a5f..4eabeac6d9869 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -24,7 +24,6 @@ use std::marker::PhantomData; use std::num::NonZeroUsize; pub use decoder::{provide, provide_extern}; -crate use encoder::encode_metadata; mod decoder; mod encoder; @@ -178,16 +177,16 @@ macro_rules! Lazy { crate struct CrateRoot<'tcx> { pub name: Symbol, pub triple: TargetTriple, - pub extra_filename: String, + extra_filename: String, pub hash: Svh, pub disambiguator: CrateDisambiguator, pub panic_strategy: PanicStrategy, - pub edition: Edition, + edition: Edition, pub has_global_allocator: bool, - pub has_panic_handler: bool, + has_panic_handler: bool, pub has_default_lib_allocator: bool, - pub plugin_registrar_fn: Option, - pub proc_macro_decls_static: Option, + plugin_registrar_fn: Option, + proc_macro_decls_static: Option, proc_macro_stability: Option, pub crate_deps: Lazy<[CrateDep]>, @@ -210,14 +209,14 @@ crate struct CrateRoot<'tcx> { /// this crate pub proc_macro_data: Option>, - pub compiler_builtins: bool, + compiler_builtins: bool, pub needs_allocator: bool, pub needs_panic_runtime: bool, - pub no_builtins: bool, + no_builtins: bool, pub panic_runtime: bool, pub profiler_runtime: bool, pub sanitizer_runtime: bool, - pub symbol_mangling_version: SymbolManglingVersion, + symbol_mangling_version: SymbolManglingVersion, } #[derive(RustcEncodable, RustcDecodable)] @@ -313,9 +312,9 @@ struct ModData { } #[derive(RustcEncodable, RustcDecodable)] -crate struct MacroDef { - pub body: String, - pub legacy: bool, +struct MacroDef { + body: String, + legacy: bool, } #[derive(RustcEncodable, RustcDecodable)] diff --git a/src/librustc_metadata/schema/decoder/cstore_impl.rs b/src/librustc_metadata/schema/decoder/cstore_impl.rs index 2d3a6f4fa9f22..59aa5c7402ffb 100644 --- a/src/librustc_metadata/schema/decoder/cstore_impl.rs +++ b/src/librustc_metadata/schema/decoder/cstore_impl.rs @@ -2,7 +2,7 @@ use crate::cstore::{self, LoadedMacro}; use crate::link_args; use crate::native_libs; use crate::foreign_modules; -use crate::schema; +use crate::schema::{self, encoder}; use rustc::ty::query::QueryConfig; use rustc::middle::cstore::{CrateSource, CrateStore, DepKind, EncodedMetadata, NativeLibraryKind}; @@ -523,7 +523,7 @@ impl CrateStore for cstore::CStore { } fn encode_metadata(&self, tcx: TyCtxt<'_>) -> EncodedMetadata { - schema::encode_metadata(tcx) + encoder::encode_metadata(tcx) } fn metadata_encoding_version(&self) -> &[u8] diff --git a/src/librustc_metadata/schema/encoder.rs b/src/librustc_metadata/schema/encoder.rs index 2119ab9c2823e..9970d753dbca8 100644 --- a/src/librustc_metadata/schema/encoder.rs +++ b/src/librustc_metadata/schema/encoder.rs @@ -1781,7 +1781,7 @@ impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> { // will allow us to slice the metadata to the precise length that we just // generated regardless of trailing bytes that end up in it. -crate fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata { +pub(super) fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata { let mut encoder = opaque::Encoder::new(vec![]); encoder.emit_raw_bytes(METADATA_HEADER); From 5eb1cf16197a8cc38d18e81338f4c148e14ee36f Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 4 Nov 2019 11:57:17 +0300 Subject: [PATCH 6/6] rustc_metadata: Rename `schema` to `rmeta` And change `rmeta.rs` to `rmeta/mod.rs` --- src/librustc_metadata/creader.rs | 2 +- src/librustc_metadata/cstore.rs | 8 ++++---- src/librustc_metadata/lib.rs | 2 +- src/librustc_metadata/locator.rs | 2 +- src/librustc_metadata/{schema => rmeta}/decoder.rs | 4 ++-- .../{schema => rmeta}/decoder/cstore_impl.rs | 4 ++-- src/librustc_metadata/{schema => rmeta}/encoder.rs | 4 ++-- src/librustc_metadata/{schema.rs => rmeta/mod.rs} | 0 src/librustc_metadata/{schema => rmeta}/table.rs | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) rename src/librustc_metadata/{schema => rmeta}/decoder.rs (99%) rename src/librustc_metadata/{schema => rmeta}/decoder/cstore_impl.rs (99%) rename src/librustc_metadata/{schema => rmeta}/encoder.rs (99%) rename src/librustc_metadata/{schema.rs => rmeta/mod.rs} (100%) rename src/librustc_metadata/{schema => rmeta}/table.rs (99%) diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 483b1a40e44d6..05e3ee3322e59 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -2,7 +2,7 @@ use crate::cstore::{self, CStore, MetadataBlob}; use crate::locator::{self, CratePaths}; -use crate::schema::{CrateRoot, CrateDep}; +use crate::rmeta::{CrateRoot, CrateDep}; use rustc_data_structures::sync::{Lock, Once, AtomicCell}; use rustc::hir::def_id::CrateNum; diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index 656ece79add92..c6c8ee575a98a 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -1,7 +1,7 @@ // The crate store - a central repo for information collected about external // crates and libraries -use crate::schema; +use crate::rmeta; use rustc::dep_graph::DepNodeIndex; use rustc::hir::def_id::{CrateNum, DefIndex}; use rustc::hir::map::definitions::DefPathTable; @@ -17,7 +17,7 @@ use syntax_expand::base::SyntaxExtension; use syntax_pos; use proc_macro::bridge::client::ProcMacro; -pub use crate::schema::{provide, provide_extern}; +pub use crate::rmeta::{provide, provide_extern}; // A map from external crate numbers (as decoded from some crate file) to // local crate numbers (as generated during this session). Each external @@ -49,7 +49,7 @@ crate struct CrateMetadata { /// lifetime is only used behind `Lazy`, and therefore acts like an /// universal (`for<'tcx>`), that is paired up with whichever `TyCtxt` /// is being used to decode those values. - crate root: schema::CrateRoot<'static>, + crate root: rmeta::CrateRoot<'static>, /// For each definition in this crate, we encode a key. When the /// crate is loaded, we read all the keys and put them in this /// hashmap, which gives the reverse mapping. This allows us to @@ -59,7 +59,7 @@ crate struct CrateMetadata { /// Trait impl data. /// FIXME: Used only from queries and can use query cache, /// so pre-decoding can probably be avoided. - crate trait_impls: FxHashMap<(u32, DefIndex), schema::Lazy<[DefIndex]>>, + crate trait_impls: FxHashMap<(u32, DefIndex), rmeta::Lazy<[DefIndex]>>, /// Proc macro descriptions for this crate, if it's a proc macro crate. crate raw_proc_macros: Option<&'static [ProcMacro]>, /// Source maps for code from the crate. diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index 516f9feb94573..ac9d78e9a515c 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -30,7 +30,7 @@ mod dependency_format; mod foreign_modules; mod link_args; mod native_libs; -mod schema; +mod rmeta; pub mod creader; pub mod cstore; diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs index 4a263250f9b0d..88d7595b063da 100644 --- a/src/librustc_metadata/locator.rs +++ b/src/librustc_metadata/locator.rs @@ -214,7 +214,7 @@ use crate::cstore::MetadataBlob; use crate::creader::Library; -use crate::schema::{METADATA_HEADER, rustc_version}; +use crate::rmeta::{METADATA_HEADER, rustc_version}; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::svh::Svh; diff --git a/src/librustc_metadata/schema/decoder.rs b/src/librustc_metadata/rmeta/decoder.rs similarity index 99% rename from src/librustc_metadata/schema/decoder.rs rename to src/librustc_metadata/rmeta/decoder.rs index 0d113cecff561..40ec04537b0e6 100644 --- a/src/librustc_metadata/schema/decoder.rs +++ b/src/librustc_metadata/rmeta/decoder.rs @@ -1,8 +1,8 @@ // Decoding metadata from a single crate's metadata use crate::cstore::{self, CrateMetadata, MetadataBlob}; -use crate::schema::*; -use crate::schema::table::{FixedSizeEncoding, PerDefTable}; +use crate::rmeta::*; +use crate::rmeta::table::{FixedSizeEncoding, PerDefTable}; use rustc_index::vec::IndexVec; use rustc_data_structures::sync::Lrc; diff --git a/src/librustc_metadata/schema/decoder/cstore_impl.rs b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs similarity index 99% rename from src/librustc_metadata/schema/decoder/cstore_impl.rs rename to src/librustc_metadata/rmeta/decoder/cstore_impl.rs index 59aa5c7402ffb..6eacfc28de2db 100644 --- a/src/librustc_metadata/schema/decoder/cstore_impl.rs +++ b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs @@ -2,7 +2,7 @@ use crate::cstore::{self, LoadedMacro}; use crate::link_args; use crate::native_libs; use crate::foreign_modules; -use crate::schema::{self, encoder}; +use crate::rmeta::{self, encoder}; use rustc::ty::query::QueryConfig; use rustc::middle::cstore::{CrateSource, CrateStore, DepKind, EncodedMetadata, NativeLibraryKind}; @@ -528,6 +528,6 @@ impl CrateStore for cstore::CStore { fn metadata_encoding_version(&self) -> &[u8] { - schema::METADATA_HEADER + rmeta::METADATA_HEADER } } diff --git a/src/librustc_metadata/schema/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs similarity index 99% rename from src/librustc_metadata/schema/encoder.rs rename to src/librustc_metadata/rmeta/encoder.rs index 9970d753dbca8..afc81649e3719 100644 --- a/src/librustc_metadata/schema/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -1,5 +1,5 @@ -use crate::schema::*; -use crate::schema::table::{FixedSizeEncoding, PerDefTable}; +use crate::rmeta::*; +use crate::rmeta::table::{FixedSizeEncoding, PerDefTable}; use rustc::middle::cstore::{LinkagePreference, NativeLibrary, EncodedMetadata, ForeignModule}; diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/rmeta/mod.rs similarity index 100% rename from src/librustc_metadata/schema.rs rename to src/librustc_metadata/rmeta/mod.rs diff --git a/src/librustc_metadata/schema/table.rs b/src/librustc_metadata/rmeta/table.rs similarity index 99% rename from src/librustc_metadata/schema/table.rs rename to src/librustc_metadata/rmeta/table.rs index cc65ab8a8ff55..613d92c6d7b0b 100644 --- a/src/librustc_metadata/schema/table.rs +++ b/src/librustc_metadata/rmeta/table.rs @@ -1,4 +1,4 @@ -use crate::schema::*; +use crate::rmeta::*; use rustc::hir::def_id::{DefId, DefIndex}; use rustc_serialize::{Encodable, opaque::Encoder};