is_exported_symbol

This commit is contained in:
achernyak 2017-05-07 21:05:31 -05:00
parent d561d4c9eb
commit 1f532bfed5
5 changed files with 11 additions and 7 deletions

View file

@ -158,6 +158,7 @@ pub enum DepNode<D: Clone + Debug> {
ConstIsRvaluePromotableToStatic(D),
ImplParent(D),
TraitOfItem(D),
IsExportedSymbol(D),
IsMirAvailable(D),
ItemAttrs(D),
FnArgNames(D),
@ -275,6 +276,7 @@ impl<D: Clone + Debug> DepNode<D> {
FnArgNames(ref d) => op(d).map(FnArgNames),
ImplParent(ref d) => op(d).map(ImplParent),
TraitOfItem(ref d) => op(d).map(TraitOfItem),
IsExportedSymbol(ref d) => op(d).map(IsExportedSymbol),
ItemBodyNestedBodies(ref d) => op(d).map(ItemBodyNestedBodies),
ConstIsRvaluePromotableToStatic(ref d) => op(d).map(ConstIsRvaluePromotableToStatic),
IsMirAvailable(ref d) => op(d).map(IsMirAvailable),

View file

@ -197,7 +197,6 @@ pub trait CrateStore {
fn is_default_impl(&self, impl_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;
// crate metadata
fn dylib_dependency_formats(&self, cnum: CrateNum)
@ -320,7 +319,6 @@ impl CrateStore for DummyCrateStore {
fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") }
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 }
// crate metadata
fn dylib_dependency_formats(&self, cnum: CrateNum)

View file

@ -341,6 +341,12 @@ impl<'tcx> QueryDescription for queries::item_attrs<'tcx> {
}
}
impl<'tcx> QueryDescription for queries::is_exported_symbol<'tcx> {
fn describe(_: TyCtxt, _: DefId) -> String {
bug!("is_exported_symbol")
}
}
impl<'tcx> QueryDescription for queries::fn_arg_names<'tcx> {
fn describe(_: TyCtxt, _: DefId) -> String {
bug!("fn_arg_names")
@ -812,6 +818,7 @@ define_maps! { <'tcx>
[] fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
[] impl_parent: ImplParent(DefId) -> Option<DefId>,
[] trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
[] is_exported_symbol: IsExportedSymbol(DefId) -> bool,
[] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
[] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
[] is_mir_available: IsMirAvailable(DefId) -> bool,

View file

@ -119,6 +119,7 @@ provide! { <'tcx> tcx, def_id, cdata
fn_arg_names => { cdata.get_fn_arg_names(def_id.index) }
impl_parent => { cdata.get_parent_impl(def_id.index) }
trait_of_item => { cdata.get_trait_of_item(def_id.index) }
is_exported_symbol => { cdata.exported_symbols.contains(&def_id.index) }
item_body_nested_bodies => { Rc::new(cdata.item_body_nested_bodies(def_id.index)) }
const_is_rvalue_promotable_to_static => {
cdata.const_is_rvalue_promotable_to_static(def_id.index)
@ -181,10 +182,6 @@ impl CrateStore for cstore::CStore {
self.do_is_statically_included_foreign_item(def_id)
}
fn is_exported_symbol(&self, def_id: DefId) -> bool {
self.get_crate_data(def_id.krate).exported_symbols.contains(&def_id.index)
}
fn is_dllimport_foreign_item(&self, def_id: DefId) -> bool {
if def_id.krate == LOCAL_CRATE {
self.dllimport_foreign_items.borrow().contains(&def_id.index)

View file

@ -652,7 +652,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) ||
if tcx.is_exported_symbol(def_id) ||
tcx.is_foreign_item(def_id)
{
// We can link to the item in question, no instance needed