Skip to content
Permalink
Browse files

Update foreign_modules and dllimport_foreign_items

  • Loading branch information...
Zoxc committed Dec 1, 2018
1 parent 2f74d90 commit 469831f4da99c9db5c3555c74313cbcf5e9f351d
@@ -94,6 +94,8 @@ macro_rules! arena_types {
[few] get_lib_features: rustc::middle::lib_features::LibFeatures,
[few] defined_lib_features: rustc::middle::lang_items::LanguageItems,
[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>,
], $tcx);
)
}
@@ -689,7 +689,7 @@ rustc_queries! {
}

Other {
query foreign_modules(_: CrateNum) -> Lrc<Vec<ForeignModule>> {
query foreign_modules(_: CrateNum) -> &'tcx [ForeignModule] {
desc { "looking up the foreign modules of a linked crate" }
}

@@ -736,7 +736,7 @@ rustc_queries! {

Other {
query dllimport_foreign_items(_: CrateNum)
-> Lrc<FxHashSet<DefId>> {
-> &'tcx FxHashSet<DefId> {
desc { "dllimport_foreign_items" }
}
query is_dllimport_foreign_item(_: DefId) -> bool {}
@@ -33,7 +33,6 @@ use rustc_mir::monomorphize::Instance;
use rustc_mir::monomorphize::partitioning::{CodegenUnit, CodegenUnitExt};
use rustc::util::nodemap::FxHashMap;
use rustc_data_structures::indexed_vec::Idx;
use rustc_data_structures::sync::Lrc;
use rustc_codegen_utils::{symbol_names_test, check_for_rustc_errors_attr};
use rustc::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
use crate::mir::place::PlaceRef;
@@ -916,7 +915,7 @@ pub fn provide_both(providers: &mut Providers<'_>) {
.map(|id| &module_map[&id])
.flat_map(|module| module.foreign_items.iter().cloned())
.collect();
Lrc::new(dllimports)
tcx.arena.alloc(dllimports)
};

providers.is_dllimport_foreign_item = |tcx, def_id| {
@@ -193,7 +193,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
Lrc::new(reachable_non_generics)
}
native_libraries => { Lrc::new(cdata.get_native_libraries(tcx.sess)) }
foreign_modules => { Lrc::new(cdata.get_foreign_modules(tcx.sess)) }
foreign_modules => { cdata.get_foreign_modules(tcx) }
plugin_registrar_fn => {
cdata.root.plugin_registrar_fn.map(|index| {
DefId { krate: def_id.krate, index }
@@ -285,7 +285,7 @@ pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
},
foreign_modules: |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
Lrc::new(foreign_modules::collect(tcx))
&tcx.arena.alloc(foreign_modules::collect(tcx))[..]
},
link_args: |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
@@ -1085,12 +1085,15 @@ impl<'a, 'tcx> CrateMetadata {
}
}

pub fn get_foreign_modules(&self, sess: &Session) -> Vec<ForeignModule> {
pub fn get_foreign_modules(
&self,
tcx: TyCtxt<'_, 'tcx, '_>,
) -> &'tcx [ForeignModule] {
if self.proc_macros.is_some() {
// Proc macro crates do not have any *target* foreign modules.
vec![]
&[]
} else {
self.root.foreign_modules.decode((self, sess)).collect()
tcx.arena.alloc_from_iter(self.root.foreign_modules.decode((self, tcx.sess)))
}
}

0 comments on commit 469831f

Please sign in to comment.
You can’t perform that action at this time.