Skip to content

Commit

Permalink
Rollup merge of rust-lang#66056 - petrochenkov:metapriv, r=eddyb
Browse files Browse the repository at this point in the history
rustc_metadata: Some reorganization of the module structure

The new structure of `rustc_metadata` (or rather its parts affected by the refactoring) is
```
├── lib.rs
└── rmeta
    ├── decoder
    │   └── cstore_impl.rs
    ├── decoder.rs
    ├── encoder.rs
    ├── mod.rs
    └── table.rs
```

(`schema` is renamed to `rmeta`.)

The code inside `rmeta` is pretty self-contained, so we can now privatize almost everything in this module instead of using `pub(crate)`  which was necessary when all these modules accessed their neighbors in the old flat structure.

`encoder` and `decoder` work with structures defined by `rmeta`.
`table` is a part of `rmeta`.
`cstore_impl` actively uses decoder methods and exposes their results through very few public methods (`provide` and `_untracked` methods).

r? @eddyb @spastorino
  • Loading branch information
JohnTitor committed Nov 8, 2019
2 parents 9dc5d0e + 5eb1cf1 commit 996d94a
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 169 deletions.
2 changes: 1 addition & 1 deletion src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_metadata/cstore.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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::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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
6 changes: 1 addition & 5 deletions src/librustc_metadata/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ 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;
mod rmeta;

pub mod creader;
pub mod cstore;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 996d94a

Please sign in to comment.