From: achernyak Date: Fri, 5 May 2017 13:15:08 +0000 (-0500) Subject: is_foreign_item X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=5a7946df703f2d9149adc0ca5c7e0b116e82a98d;p=rust.git is_foreign_item --- diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index e50072043d5..d9ce40a0d7d 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 @@ fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem // 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 d2b8ed8c297..4bbf37b21ed 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -205,7 +205,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) { } 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 a0c887e95d6..7bd431ff446 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -176,10 +176,6 @@ fn is_default_impl(&self, impl_did: DefId) -> bool { 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 aef9140ba45..1aed2932948 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 6d7d95f5487..f0be0941ccf 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 6afb340107d..eac0a062567 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'.