Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc_metadata: parametrize schema::CrateRoot by 'tcx and rip out old unused incremental infra. #61034

Merged
merged 2 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl<'a> CrateLoader<'a> {

fn verify_no_symbol_conflicts(&self,
span: Span,
root: &CrateRoot) {
root: &CrateRoot<'_>) {
// Check for (potential) conflicts with the local crate
if self.local_crate_name == root.name &&
self.sess.local_crate_disambiguator() == root.disambiguator {
Expand Down Expand Up @@ -476,7 +476,7 @@ impl<'a> CrateLoader<'a> {
// Go through the crate metadata and load any crates that it references
fn resolve_crate_deps(&mut self,
root: &Option<CratePaths>,
crate_root: &CrateRoot,
crate_root: &CrateRoot<'_>,
metadata: &MetadataBlob,
krate: CrateNum,
span: Span,
Expand Down Expand Up @@ -582,7 +582,7 @@ impl<'a> CrateLoader<'a> {
/// implemented as dynamic libraries, but we have a possible future where
/// custom derive (and other macro-1.1 style features) are implemented via
/// executables and custom IPC.
fn load_derive_macros(&mut self, root: &CrateRoot, dylib: Option<PathBuf>, span: Span)
fn load_derive_macros(&mut self, root: &CrateRoot<'_>, dylib: Option<PathBuf>, span: Span)
-> Vec<(ast::Name, Lrc<SyntaxExtension>)> {
use std::{env, mem};
use crate::dynamic_lib::DynamicLibrary;
Expand Down
6 changes: 5 additions & 1 deletion src/librustc_metadata/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ pub struct CrateMetadata {
/// Used for decoding interpret::AllocIds in a cached & thread-safe manner.
pub alloc_decoding_state: AllocDecodingState,

pub root: schema::CrateRoot,
// NOTE(eddyb) we pass `'static` to a `'tcx` parameter because this
// lifetime is only used behind `Lazy` / `LazySeq`, and therefore
// acts like an universal (`for<'tcx>`), that is paired up with
// whichever `TyCtxt` is being used to decode those values.
pub root: schema::CrateRoot<'static>,

/// For each public item in this crate, we encode a key. When the
/// crate is loaded, we read all the keys and put them in this
Expand Down
7 changes: 1 addition & 6 deletions src/librustc_metadata/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,

used_crate_source => { Lrc::new(cdata.source.clone()) }

exported_symbols => {
let cnum = cdata.cnum;
assert!(cnum != LOCAL_CRATE);

Arc::new(cdata.exported_symbols(tcx))
}
exported_symbols => { Arc::new(cdata.exported_symbols(tcx)) }
}

pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
Expand Down
13 changes: 5 additions & 8 deletions src/librustc_metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ for DecodeContext<'a, 'tcx> {

implement_ty_decoder!( DecodeContext<'a, 'tcx> );

impl<'a, 'tcx> MetadataBlob {
impl<'tcx> MetadataBlob {
pub fn is_compatible(&self) -> bool {
self.raw_bytes().starts_with(METADATA_HEADER)
}
Expand All @@ -374,7 +374,7 @@ impl<'a, 'tcx> MetadataBlob {
Lazy::with_position(METADATA_HEADER.len() + 4).decode(self)
}

pub fn get_root(&self) -> CrateRoot {
pub fn get_root(&self) -> CrateRoot<'tcx> {
let slice = self.raw_bytes();
let offset = METADATA_HEADER.len();
let pos = (((slice[offset + 0] as u32) << 24) | ((slice[offset + 1] as u32) << 16) |
Expand Down Expand Up @@ -444,7 +444,7 @@ impl<'tcx> EntryKind<'tcx> {
/// |- proc macro #0 (DefIndex 1:N)
/// |- proc macro #1 (DefIndex 1:N+1)
/// \- ...
crate fn proc_macro_def_path_table(crate_root: &CrateRoot,
crate fn proc_macro_def_path_table(crate_root: &CrateRoot<'_>,
proc_macros: &[(ast::Name, Lrc<SyntaxExtension>)])
-> DefPathTable
{
Expand Down Expand Up @@ -475,7 +475,7 @@ impl<'a, 'tcx> CrateMetadata {

fn maybe_entry(&self, item_id: DefIndex) -> Option<Lazy<Entry<'tcx>>> {
assert!(!self.is_proc_macro(item_id));
self.root.index.lookup(self.blob.raw_bytes(), item_id)
self.root.entries_index.lookup(self.blob.raw_bytes(), item_id)
}

fn entry(&self, item_id: DefIndex) -> Entry<'tcx> {
Expand Down Expand Up @@ -1126,10 +1126,7 @@ impl<'a, 'tcx> CrateMetadata {
// link those in so we skip those crates.
vec![]
} else {
let lazy_seq: LazySeq<(ExportedSymbol<'tcx>, SymbolExportLevel)> =
LazySeq::with_position_and_length(self.root.exported_symbols.position,
self.root.exported_symbols.len);
lazy_seq.decode((self, tcx)).collect()
self.root.exported_symbols.decode((self, tcx)).collect()
}
}

Expand Down
Loading