Skip to content

Commit d327e6e

Browse files
authored
Rollup merge of #61034 - eddyb:soa-metadata-prereq, r=michaelwoerister
rustc_metadata: parametrize schema::CrateRoot by 'tcx and rip out old unused incremental infra. These are the first two commits of #59953, already reviewed and approved by @michaelwoerister. r? @michaelwoerister
2 parents 21ba931 + 7327768 commit d327e6e

File tree

10 files changed

+157
-665
lines changed

10 files changed

+157
-665
lines changed

Diff for: src/librustc_metadata/creader.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl<'a> CrateLoader<'a> {
162162

163163
fn verify_no_symbol_conflicts(&self,
164164
span: Span,
165-
root: &CrateRoot) {
165+
root: &CrateRoot<'_>) {
166166
// Check for (potential) conflicts with the local crate
167167
if self.local_crate_name == root.name &&
168168
self.sess.local_crate_disambiguator() == root.disambiguator {
@@ -476,7 +476,7 @@ impl<'a> CrateLoader<'a> {
476476
// Go through the crate metadata and load any crates that it references
477477
fn resolve_crate_deps(&mut self,
478478
root: &Option<CratePaths>,
479-
crate_root: &CrateRoot,
479+
crate_root: &CrateRoot<'_>,
480480
metadata: &MetadataBlob,
481481
krate: CrateNum,
482482
span: Span,
@@ -582,7 +582,7 @@ impl<'a> CrateLoader<'a> {
582582
/// implemented as dynamic libraries, but we have a possible future where
583583
/// custom derive (and other macro-1.1 style features) are implemented via
584584
/// executables and custom IPC.
585-
fn load_derive_macros(&mut self, root: &CrateRoot, dylib: Option<PathBuf>, span: Span)
585+
fn load_derive_macros(&mut self, root: &CrateRoot<'_>, dylib: Option<PathBuf>, span: Span)
586586
-> Vec<(ast::Name, Lrc<SyntaxExtension>)> {
587587
use std::{env, mem};
588588
use crate::dynamic_lib::DynamicLibrary;

Diff for: src/librustc_metadata/cstore.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ pub struct CrateMetadata {
6464
/// Used for decoding interpret::AllocIds in a cached & thread-safe manner.
6565
pub alloc_decoding_state: AllocDecodingState,
6666

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

6973
/// For each public item in this crate, we encode a key. When the
7074
/// crate is loaded, we read all the keys and put them in this

Diff for: src/librustc_metadata/cstore_impl.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
246246

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

249-
exported_symbols => {
250-
let cnum = cdata.cnum;
251-
assert!(cnum != LOCAL_CRATE);
252-
253-
Arc::new(cdata.exported_symbols(tcx))
254-
}
249+
exported_symbols => { Arc::new(cdata.exported_symbols(tcx)) }
255250
}
256251

257252
pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {

Diff for: src/librustc_metadata/decoder.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ for DecodeContext<'a, 'tcx> {
365365

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

368-
impl<'a, 'tcx> MetadataBlob {
368+
impl<'tcx> MetadataBlob {
369369
pub fn is_compatible(&self) -> bool {
370370
self.raw_bytes().starts_with(METADATA_HEADER)
371371
}
@@ -374,7 +374,7 @@ impl<'a, 'tcx> MetadataBlob {
374374
Lazy::with_position(METADATA_HEADER.len() + 4).decode(self)
375375
}
376376

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

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

481481
fn entry(&self, item_id: DefIndex) -> Entry<'tcx> {
@@ -1126,10 +1126,7 @@ impl<'a, 'tcx> CrateMetadata {
11261126
// link those in so we skip those crates.
11271127
vec![]
11281128
} else {
1129-
let lazy_seq: LazySeq<(ExportedSymbol<'tcx>, SymbolExportLevel)> =
1130-
LazySeq::with_position_and_length(self.root.exported_symbols.position,
1131-
self.root.exported_symbols.len);
1132-
lazy_seq.decode((self, tcx)).collect()
1129+
self.root.exported_symbols.decode((self, tcx)).collect()
11331130
}
11341131
}
11351132

0 commit comments

Comments
 (0)