Skip to content

Commit 1f532bf

Browse files
committed
is_exported_symbol
1 parent d561d4c commit 1f532bf

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ pub enum DepNode<D: Clone + Debug> {
158158
ConstIsRvaluePromotableToStatic(D),
159159
ImplParent(D),
160160
TraitOfItem(D),
161+
IsExportedSymbol(D),
161162
IsMirAvailable(D),
162163
ItemAttrs(D),
163164
FnArgNames(D),
@@ -275,6 +276,7 @@ impl<D: Clone + Debug> DepNode<D> {
275276
FnArgNames(ref d) => op(d).map(FnArgNames),
276277
ImplParent(ref d) => op(d).map(ImplParent),
277278
TraitOfItem(ref d) => op(d).map(TraitOfItem),
279+
IsExportedSymbol(ref d) => op(d).map(IsExportedSymbol),
278280
ItemBodyNestedBodies(ref d) => op(d).map(ItemBodyNestedBodies),
279281
ConstIsRvaluePromotableToStatic(ref d) => op(d).map(ConstIsRvaluePromotableToStatic),
280282
IsMirAvailable(ref d) => op(d).map(IsMirAvailable),

src/librustc/middle/cstore.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ pub trait CrateStore {
197197
fn is_default_impl(&self, impl_did: DefId) -> bool;
198198
fn is_dllimport_foreign_item(&self, def: DefId) -> bool;
199199
fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool;
200-
fn is_exported_symbol(&self, def_id: DefId) -> bool;
201200

202201
// crate metadata
203202
fn dylib_dependency_formats(&self, cnum: CrateNum)
@@ -320,7 +319,6 @@ impl CrateStore for DummyCrateStore {
320319
fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") }
321320
fn is_dllimport_foreign_item(&self, id: DefId) -> bool { false }
322321
fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { false }
323-
fn is_exported_symbol(&self, def_id: DefId) -> bool { false }
324322

325323
// crate metadata
326324
fn dylib_dependency_formats(&self, cnum: CrateNum)

src/librustc/ty/maps.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,12 @@ impl<'tcx> QueryDescription for queries::item_attrs<'tcx> {
341341
}
342342
}
343343

344+
impl<'tcx> QueryDescription for queries::is_exported_symbol<'tcx> {
345+
fn describe(_: TyCtxt, _: DefId) -> String {
346+
bug!("is_exported_symbol")
347+
}
348+
}
349+
344350
impl<'tcx> QueryDescription for queries::fn_arg_names<'tcx> {
345351
fn describe(_: TyCtxt, _: DefId) -> String {
346352
bug!("fn_arg_names")
@@ -812,6 +818,7 @@ define_maps! { <'tcx>
812818
[] fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
813819
[] impl_parent: ImplParent(DefId) -> Option<DefId>,
814820
[] trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
821+
[] is_exported_symbol: IsExportedSymbol(DefId) -> bool,
815822
[] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
816823
[] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
817824
[] is_mir_available: IsMirAvailable(DefId) -> bool,

src/librustc_metadata/cstore_impl.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ provide! { <'tcx> tcx, def_id, cdata
119119
fn_arg_names => { cdata.get_fn_arg_names(def_id.index) }
120120
impl_parent => { cdata.get_parent_impl(def_id.index) }
121121
trait_of_item => { cdata.get_trait_of_item(def_id.index) }
122+
is_exported_symbol => { cdata.exported_symbols.contains(&def_id.index) }
122123
item_body_nested_bodies => { Rc::new(cdata.item_body_nested_bodies(def_id.index)) }
123124
const_is_rvalue_promotable_to_static => {
124125
cdata.const_is_rvalue_promotable_to_static(def_id.index)
@@ -181,10 +182,6 @@ impl CrateStore for cstore::CStore {
181182
self.do_is_statically_included_foreign_item(def_id)
182183
}
183184

184-
fn is_exported_symbol(&self, def_id: DefId) -> bool {
185-
self.get_crate_data(def_id.krate).exported_symbols.contains(&def_id.index)
186-
}
187-
188185
fn is_dllimport_foreign_item(&self, def_id: DefId) -> bool {
189186
if def_id.krate == LOCAL_CRATE {
190187
self.dllimport_foreign_items.borrow().contains(&def_id.index)

src/librustc_trans/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ fn should_trans_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instan
652652
}
653653
Some(_) => true,
654654
None => {
655-
if tcx.sess.cstore.is_exported_symbol(def_id) ||
655+
if tcx.is_exported_symbol(def_id) ||
656656
tcx.is_foreign_item(def_id)
657657
{
658658
// We can link to the item in question, no instance needed

0 commit comments

Comments
 (0)