Skip to content

Commit f2487b8

Browse files
committed
refactor metadata_symbol_name
1 parent 8e26983 commit f2487b8

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/librustc_trans/back/symbol_export.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use back::symbol_names::symbol_name;
1515
use util::nodemap::FxHashMap;
1616
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
1717
use rustc::session::config;
18+
use rustc::ty::TyCtxt;
1819
use syntax::attr;
1920
use trans_item::TransItem;
2021

@@ -72,7 +73,7 @@ impl ExportedSymbols {
7273
}
7374

7475
if scx.sess().crate_types.borrow().contains(&config::CrateTypeDylib) {
75-
local_crate.push((scx.metadata_symbol_name(),
76+
local_crate.push((metadata_symbol_name(scx.tcx()),
7677
SymbolExportLevel::Rust));
7778
}
7879

@@ -173,6 +174,12 @@ impl ExportedSymbols {
173174
}
174175
}
175176

177+
pub fn metadata_symbol_name(tcx: TyCtxt) -> String {
178+
format!("rust_metadata_{}_{}",
179+
tcx.crate_name(LOCAL_CRATE),
180+
tcx.crate_disambiguator(LOCAL_CRATE))
181+
}
182+
176183
pub fn crate_export_threshold(crate_type: config::CrateType)
177184
-> SymbolExportLevel {
178185
match crate_type {

src/librustc_trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ fn write_metadata(cx: &SharedCrateContext,
776776

777777
let llmeta = C_bytes_in_context(metadata_llcx, &compressed);
778778
let llconst = C_struct_in_context(metadata_llcx, &[llmeta], false);
779-
let name = cx.metadata_symbol_name();
779+
let name = symbol_export::metadata_symbol_name(cx.tcx());
780780
let buf = CString::new(name).unwrap();
781781
let llglobal = unsafe {
782782
llvm::LLVMAddGlobal(metadata_llmod, val_ty(llconst).to_ref(), buf.as_ptr())

src/librustc_trans/context.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use llvm;
1212
use llvm::{ContextRef, ModuleRef, ValueRef};
1313
use rustc::dep_graph::{DepGraph, DepGraphSafe, DepNode, DepTrackingMap, DepTrackingMapConfig};
1414
use rustc::hir;
15-
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
15+
use rustc::hir::def_id::DefId;
1616
use rustc::traits;
1717
use debuginfo;
1818
use callee;
@@ -430,12 +430,6 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
430430
pub fn translation_items(&self) -> &RefCell<FxHashSet<TransItem<'tcx>>> {
431431
&self.translation_items
432432
}
433-
434-
pub fn metadata_symbol_name(&self) -> String {
435-
format!("rust_metadata_{}_{}",
436-
self.tcx().crate_name(LOCAL_CRATE),
437-
self.tcx().crate_disambiguator(LOCAL_CRATE))
438-
}
439433
}
440434

441435
impl<'tcx> LocalCrateContext<'tcx> {

0 commit comments

Comments
 (0)