]> git.lizzy.rs Git - rust.git/commitdiff
refactor `metadata_symbol_name`
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 13 Apr 2017 22:08:36 +0000 (18:08 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 13 Apr 2017 22:37:47 +0000 (18:37 -0400)
src/librustc_trans/back/symbol_export.rs
src/librustc_trans/base.rs
src/librustc_trans/context.rs

index 04617edf4a7a972e3fbba39599b348e04063c9d0..5d6717272fdf3d000fdea7c56f5a14815f081cc1 100644 (file)
@@ -15,6 +15,7 @@
 use util::nodemap::FxHashMap;
 use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
 use rustc::session::config;
+use rustc::ty::TyCtxt;
 use syntax::attr;
 use trans_item::TransItem;
 
@@ -72,7 +73,7 @@ pub fn compute_from<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
         }
 
         if scx.sess().crate_types.borrow().contains(&config::CrateTypeDylib) {
-            local_crate.push((scx.metadata_symbol_name(),
+            local_crate.push((metadata_symbol_name(scx.tcx()),
                               SymbolExportLevel::Rust));
         }
 
@@ -173,6 +174,12 @@ pub fn for_each_exported_symbol<F>(&self,
     }
 }
 
+pub fn metadata_symbol_name(tcx: TyCtxt) -> String {
+    format!("rust_metadata_{}_{}",
+            tcx.crate_name(LOCAL_CRATE),
+            tcx.crate_disambiguator(LOCAL_CRATE))
+}
+
 pub fn crate_export_threshold(crate_type: config::CrateType)
                                      -> SymbolExportLevel {
     match crate_type {
index 3fd966eb73ee6bd32a1dfac023c996463599b3a0..b364814d07e80f3d15e135a0cdf6011de72514fd 100644 (file)
@@ -776,7 +776,7 @@ enum MetadataKind {
 
     let llmeta = C_bytes_in_context(metadata_llcx, &compressed);
     let llconst = C_struct_in_context(metadata_llcx, &[llmeta], false);
-    let name = cx.metadata_symbol_name();
+    let name = symbol_export::metadata_symbol_name(cx.tcx());
     let buf = CString::new(name).unwrap();
     let llglobal = unsafe {
         llvm::LLVMAddGlobal(metadata_llmod, val_ty(llconst).to_ref(), buf.as_ptr())
index 7e49dee498d003047ae4a72446ffda5b3a2978be..c3770470bfd056536d620c38affa728d11e11aa7 100644 (file)
@@ -12,7 +12,7 @@
 use llvm::{ContextRef, ModuleRef, ValueRef};
 use rustc::dep_graph::{DepGraph, DepGraphSafe, DepNode, DepTrackingMap, DepTrackingMapConfig};
 use rustc::hir;
-use rustc::hir::def_id::{DefId, LOCAL_CRATE};
+use rustc::hir::def_id::DefId;
 use rustc::traits;
 use debuginfo;
 use callee;
@@ -430,12 +430,6 @@ pub fn use_dll_storage_attrs(&self) -> bool {
     pub fn translation_items(&self) -> &RefCell<FxHashSet<TransItem<'tcx>>> {
         &self.translation_items
     }
-
-    pub fn metadata_symbol_name(&self) -> String {
-        format!("rust_metadata_{}_{}",
-                self.tcx().crate_name(LOCAL_CRATE),
-                self.tcx().crate_disambiguator(LOCAL_CRATE))
-    }
 }
 
 impl<'tcx> LocalCrateContext<'tcx> {