Update dylib_dependency_formats, extern_crate and reachable_non_generics

This commit is contained in:
John Kåre Alsaker 2018-12-01 17:27:12 +01:00
parent 469831f4da
commit a58999c19e
7 changed files with 23 additions and 19 deletions

View file

@ -96,6 +96,9 @@ macro_rules! arena_types {
[few] visible_parent_map: rustc::util::nodemap::DefIdMap<rustc::hir::def_id::DefId>,
[few] foreign_module: rustc::middle::cstore::ForeignModule,
[few] foreign_modules: Vec<rustc::middle::cstore::ForeignModule>,
[few] reachable_non_generics: rustc::util::nodemap::DefIdMap<
rustc::middle::exported_symbols::SymbolExportLevel
>,
], $tcx);
)
}

View file

@ -590,7 +590,7 @@ rustc_queries! {
Other {
query dylib_dependency_formats(_: CrateNum)
-> Lrc<Vec<(CrateNum, LinkagePreference)>> {
-> &'tcx [(CrateNum, LinkagePreference)] {
desc { "dylib dependency formats of crate" }
}
}
@ -625,7 +625,7 @@ rustc_queries! {
desc { "test whether a crate has #![no_builtins]" }
}
query extern_crate(_: DefId) -> Lrc<Option<ExternCrate>> {
query extern_crate(_: DefId) -> Option<&'tcx ExternCrate> {
eval_always
desc { "getting crate's ExternCrateData" }
}
@ -671,7 +671,7 @@ rustc_queries! {
// Does not include external symbols that don't have a corresponding DefId,
// like the compiler-generated `main` function and so on.
query reachable_non_generics(_: CrateNum)
-> Lrc<DefIdMap<SymbolExportLevel>> {
-> &'tcx DefIdMap<SymbolExportLevel> {
desc { "looking up the exported symbols of a crate" }
}
query is_reachable_non_generic(_: DefId) -> bool {}

View file

@ -253,8 +253,8 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>:
// 2. for an extern inferred from a path or an indirect crate,
// where there is no explicit `extern crate`, we just prepend
// the crate name.
match *self.tcx().extern_crate(def_id) {
Some(ExternCrate {
match self.tcx().extern_crate(def_id) {
Some(&ExternCrate {
src: ExternCrateSource::Extern(def_id),
direct: true,
span,

View file

@ -1,4 +1,3 @@
use rustc_data_structures::sync::Lrc;
use std::sync::Arc;
use rustc::ty::Instance;
@ -49,12 +48,12 @@ pub fn crates_export_threshold(crate_types: &[config::CrateType]) -> SymbolExpor
fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
cnum: CrateNum)
-> Lrc<DefIdMap<SymbolExportLevel>>
-> &'tcx DefIdMap<SymbolExportLevel>
{
assert_eq!(cnum, LOCAL_CRATE);
if !tcx.sess.opts.output_types.should_codegen() {
return Default::default();
return tcx.arena.alloc(Default::default());
}
// Check to see if this crate is a "special runtime crate". These
@ -155,7 +154,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
reachable_non_generics.insert(id, SymbolExportLevel::C);
}
Lrc::new(reachable_non_generics)
tcx.arena.alloc(reachable_non_generics)
}
fn is_reachable_non_generic_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

View file

@ -163,7 +163,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
}
is_mir_available => { cdata.is_item_mir_available(def_id.index) }
dylib_dependency_formats => { Lrc::new(cdata.get_dylib_dependency_formats()) }
dylib_dependency_formats => { cdata.get_dylib_dependency_formats(tcx) }
is_panic_runtime => { cdata.root.panic_runtime }
is_compiler_builtins => { cdata.root.compiler_builtins }
has_global_allocator => { cdata.root.has_global_allocator }
@ -172,8 +172,8 @@ provide! { <'tcx> tcx, def_id, other, cdata,
is_profiler_runtime => { cdata.root.profiler_runtime }
panic_strategy => { cdata.root.panic_strategy }
extern_crate => {
let r = Lrc::new(*cdata.extern_crate.lock());
r
let r = *cdata.extern_crate.lock();
r.map(|c| &*tcx.arena.alloc(c))
}
is_no_builtins => { cdata.root.no_builtins }
impl_defaultness => { cdata.get_impl_defaultness(def_id.index) }
@ -190,7 +190,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
})
.collect();
Lrc::new(reachable_non_generics)
tcx.arena.alloc(reachable_non_generics)
}
native_libraries => { Lrc::new(cdata.get_native_libraries(tcx.sess)) }
foreign_modules => { cdata.get_foreign_modules(tcx) }

View file

@ -1097,16 +1097,18 @@ impl<'a, 'tcx> CrateMetadata {
}
}
pub fn get_dylib_dependency_formats(&self) -> Vec<(CrateNum, LinkagePreference)> {
self.root
pub fn get_dylib_dependency_formats(
&self,
tcx: TyCtxt<'_, 'tcx, '_>,
) -> &'tcx [(CrateNum, LinkagePreference)] {
tcx.arena.alloc_from_iter(self.root
.dylib_dependency_formats
.decode(self)
.enumerate()
.flat_map(|(i, link)| {
let cnum = CrateNum::new(i + 1);
link.map(|link| (self.cnum_map[cnum], link))
})
.collect()
}))
}
pub fn get_missing_lang_items(

View file

@ -109,8 +109,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
let mut result = Vec::with_capacity(self.tcx.crates().len());
for &n in self.tcx.crates().iter() {
let span = match *self.tcx.extern_crate(n.as_def_id()) {
Some(ExternCrate { span, .. }) => span,
let span = match self.tcx.extern_crate(n.as_def_id()) {
Some(&ExternCrate { span, .. }) => span,
None => {
debug!("Skipping crate {}, no data", n);
continue;