From 5a7946df703f2d9149adc0ca5c7e0b116e82a98d Mon Sep 17 00:00:00 2001 From: achernyak Date: Fri, 5 May 2017 08:15:08 -0500 Subject: [PATCH] is_foreign_item --- src/librustc/middle/cstore.rs | 2 -- src/librustc/middle/effect.rs | 2 +- src/librustc_metadata/cstore_impl.rs | 4 ---- src/librustc_trans/back/symbol_names.rs | 2 +- src/librustc_trans/collector.rs | 2 +- src/librustc_trans/consts.rs | 2 +- 6 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index e50072043d5f7..d9ce40a0d7de2 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -195,7 +195,6 @@ pub trait CrateStore { // flags fn is_const_fn(&self, did: DefId) -> bool; fn is_default_impl(&self, impl_did: DefId) -> bool; - fn is_foreign_item(&self, did: DefId) -> bool; fn is_dllimport_foreign_item(&self, def: DefId) -> bool; fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool; fn is_exported_symbol(&self, def_id: DefId) -> bool; @@ -319,7 +318,6 @@ impl CrateStore for DummyCrateStore { // flags fn is_const_fn(&self, did: DefId) -> bool { bug!("is_const_fn") } fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") } - fn is_foreign_item(&self, did: DefId) -> bool { bug!("is_foreign_item") } fn is_dllimport_foreign_item(&self, id: DefId) -> bool { false } fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { false } fn is_exported_symbol(&self, def_id: DefId) -> bool { false } diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index d2b8ed8c29707..4bbf37b21edbf 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -205,7 +205,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EffectCheckVisitor<'a, 'tcx> { } else if match self.tcx.hir.get_if_local(def_id) { Some(hir::map::NodeForeignItem(..)) => true, Some(..) => false, - None => self.tcx.sess.cstore.is_foreign_item(def_id), + None => self.tcx.is_foreign_item(def_id), } { self.require_unsafe_ext(expr.id, expr.span, "use of extern static", true); } diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index a0c887e95d6c7..7bd431ff44621 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -176,10 +176,6 @@ impl CrateStore for cstore::CStore { self.get_crate_data(impl_did.krate).is_default_impl(impl_did.index) } - fn is_foreign_item(&self, did: DefId) -> bool { - self.get_crate_data(did.krate).is_foreign_item(did.index) - } - fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { self.do_is_statically_included_foreign_item(def_id) diff --git a/src/librustc_trans/back/symbol_names.rs b/src/librustc_trans/back/symbol_names.rs index aef9140ba4556..1aed293294802 100644 --- a/src/librustc_trans/back/symbol_names.rs +++ b/src/librustc_trans/back/symbol_names.rs @@ -223,7 +223,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance _ => false } } else { - tcx.sess.cstore.is_foreign_item(def_id) + tcx.is_foreign_item(def_id) }; if let Some(name) = weak_lang_items::link_name(&attrs) { diff --git a/src/librustc_trans/collector.rs b/src/librustc_trans/collector.rs index 6d7d95f548721..f0be0941ccf36 100644 --- a/src/librustc_trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -653,7 +653,7 @@ fn should_trans_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instan Some(_) => true, None => { if tcx.sess.cstore.is_exported_symbol(def_id) || - tcx.sess.cstore.is_foreign_item(def_id) + tcx.is_foreign_item(def_id) { // We can link to the item in question, no instance needed // in this crate diff --git a/src/librustc_trans/consts.rs b/src/librustc_trans/consts.rs index 6afb340107d66..eac0a06256719 100644 --- a/src/librustc_trans/consts.rs +++ b/src/librustc_trans/consts.rs @@ -186,7 +186,7 @@ pub fn get_static(ccx: &CrateContext, def_id: DefId) -> ValueRef { llvm::set_thread_local(g, true); } } - if ccx.use_dll_storage_attrs() && !ccx.sess().cstore.is_foreign_item(def_id) { + if ccx.use_dll_storage_attrs() && !ccx.tcx().is_foreign_item(def_id) { // This item is external but not foreign, i.e. it originates from an external Rust // crate. Since we don't know whether this crate will be linked dynamically or // statically in the final application, we always mark such symbols as 'dllimport'.