Skip to content

Commit

Permalink
Update dylib_dependency_formats, extern_crate and reachable_non_generics
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed May 23, 2019
1 parent 469831f commit a58999c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 19 deletions.
3 changes: 3 additions & 0 deletions src/librustc/arena.rs
Expand Up @@ -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);
)
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/query/mod.rs
Expand Up @@ -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" }
}
}
Expand Down Expand Up @@ -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" }
}
Expand Down Expand Up @@ -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 {}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/print/pretty.rs
Expand Up @@ -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,
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_codegen_ssa/back/symbol_export.rs
@@ -1,4 +1,3 @@
use rustc_data_structures::sync::Lrc;
use std::sync::Arc;

use rustc::ty::Instance;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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>,
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_metadata/cstore_impl.rs
Expand Up @@ -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 }
Expand All @@ -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) }
Expand All @@ -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) }
Expand Down
10 changes: 6 additions & 4 deletions src/librustc_metadata/decoder.rs
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_save_analysis/lib.rs
Expand Up @@ -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;
Expand Down

0 comments on commit a58999c

Please sign in to comment.