Skip to content

Commit

Permalink
is_exported_symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
hackeryarn committed May 8, 2017
1 parent d561d4c commit 1f532bf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/librustc/dep_graph/dep_node.rs
Expand Up @@ -158,6 +158,7 @@ pub enum DepNode<D: Clone + Debug> {
ConstIsRvaluePromotableToStatic(D),
ImplParent(D),
TraitOfItem(D),
IsExportedSymbol(D),
IsMirAvailable(D),
ItemAttrs(D),
FnArgNames(D),
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 0 additions & 2 deletions src/librustc/middle/cstore.rs
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions src/librustc/ty/maps.rs
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions src/librustc_metadata/cstore_impl.rs
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/collector.rs
Expand Up @@ -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
Expand Down

0 comments on commit 1f532bf

Please sign in to comment.