Skip to content

Commit c22fdf9

Browse files
committed
use tcx.crate_name(LOCAL_CRATE) rather than LinkMeta::crate_name
1 parent 3f59079 commit c22fdf9

File tree

8 files changed

+14
-15
lines changed

8 files changed

+14
-15
lines changed

src/librustc/middle/cstore.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ pub use self::NativeLibraryKind::*;
5353

5454
#[derive(Clone, Debug)]
5555
pub struct LinkMeta {
56-
pub crate_name: Symbol,
5756
pub crate_hash: Svh,
5857
}
5958

src/librustc_driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ pub fn phase_6_link_output(sess: &Session,
11401140
outputs: &OutputFilenames) {
11411141
time(sess.time_passes(),
11421142
"linking",
1143-
|| link::link_binary(sess, trans, outputs, &trans.link.crate_name.as_str()));
1143+
|| link::link_binary(sess, trans, outputs, &trans.crate_name.as_str()));
11441144
}
11451145

11461146
fn escape_dep_filename(filename: &str) -> String {

src/librustc_metadata/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use schema::*;
1414

1515
use rustc::middle::cstore::{LinkMeta, LinkagePreference, NativeLibrary,
1616
EncodedMetadata, EncodedMetadataHash};
17-
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId};
17+
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId, LOCAL_CRATE};
1818
use rustc::hir::map::definitions::DefPathTable;
1919
use rustc::middle::dependency_format::Linkage;
2020
use rustc::middle::lang_items;
@@ -1380,7 +1380,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13801380
let link_meta = self.link_meta;
13811381
let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateTypeProcMacro);
13821382
let root = self.lazy(&CrateRoot {
1383-
name: link_meta.crate_name,
1383+
name: tcx.crate_name(LOCAL_CRATE),
13841384
triple: tcx.sess.opts.target_triple.clone(),
13851385
hash: link_meta.crate_hash,
13861386
disambiguator: tcx.sess.local_crate_disambiguator(),

src/librustc_trans/back/link.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ use std::str;
4747
use flate;
4848
use syntax::ast;
4949
use syntax::attr;
50-
use syntax::symbol::Symbol;
5150
use syntax_pos::Span;
5251

5352
/// The LLVM module name containing crate-metadata. This includes a `.` on
@@ -136,11 +135,8 @@ pub fn find_crate_name(sess: Option<&Session>,
136135
"rust_out".to_string()
137136
}
138137

139-
pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap,
140-
name: &str)
141-
-> LinkMeta {
138+
pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap) -> LinkMeta {
142139
let r = LinkMeta {
143-
crate_name: Symbol::intern(name),
144140
crate_hash: Svh::new(incremental_hashes_map[&DepNode::Krate].to_smaller_hash()),
145141
};
146142
info!("{:?}", r);

src/librustc_trans/base.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,12 +1063,12 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
10631063
// particular items that will be processed.
10641064
let krate = tcx.hir.krate();
10651065

1066-
let ty::CrateAnalysis { reachable, name, .. } = analysis;
1066+
let ty::CrateAnalysis { reachable, .. } = analysis;
10671067
let exported_symbols = find_exported_symbols(tcx, reachable);
10681068

10691069
let check_overflow = tcx.sess.overflow_checks();
10701070

1071-
let link_meta = link::build_link_meta(incremental_hashes_map, &name);
1071+
let link_meta = link::build_link_meta(incremental_hashes_map);
10721072

10731073
let shared_ccx = SharedCrateContext::new(tcx,
10741074
link_meta.clone(),
@@ -1096,6 +1096,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
10961096
let empty_exported_symbols = ExportedSymbols::empty();
10971097
let linker_info = LinkerInfo::new(&shared_ccx, &empty_exported_symbols);
10981098
return CrateTranslation {
1099+
crate_name: tcx.crate_name(LOCAL_CRATE),
10991100
modules: vec![],
11001101
metadata_module: metadata_module,
11011102
link: link_meta,
@@ -1307,6 +1308,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
13071308
});
13081309

13091310
CrateTranslation {
1311+
crate_name: tcx.crate_name(LOCAL_CRATE),
13101312
modules: modules,
13111313
metadata_module: metadata_module,
13121314
link: link_meta,

src/librustc_trans/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use llvm::{ContextRef, ModuleRef, ValueRef};
1313
use rustc::dep_graph::{DepGraph, DepGraphSafe, DepNode, DepTrackingMap, DepTrackingMapConfig};
1414
use middle::cstore::LinkMeta;
1515
use rustc::hir;
16-
use rustc::hir::def_id::DefId;
16+
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
1717
use rustc::traits;
1818
use debuginfo;
1919
use callee;
@@ -439,7 +439,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
439439

440440
pub fn metadata_symbol_name(&self) -> String {
441441
format!("rust_metadata_{}_{}",
442-
self.link_meta().crate_name,
442+
self.tcx().crate_name(LOCAL_CRATE),
443443
self.link_meta().crate_hash)
444444
}
445445
}

src/librustc_trans/debuginfo/metadata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor,
2626
DICompositeType, DILexicalBlock, DIFlags};
2727

2828
use rustc::hir::def::CtorKind;
29-
use rustc::hir::def_id::DefId;
29+
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
3030
use rustc::ty::fold::TypeVisitor;
3131
use rustc::ty::subst::Substs;
3232
use rustc::ty::util::TypeIdHasher;
@@ -810,7 +810,7 @@ pub fn compile_unit_metadata(scc: &SharedCrateContext,
810810
};
811811

812812
fn fallback_path(scc: &SharedCrateContext) -> CString {
813-
CString::new(scc.link_meta().crate_name.to_string()).unwrap()
813+
CString::new(scc.tcx().crate_name(LOCAL_CRATE).to_string()).unwrap()
814814
}
815815
}
816816

src/librustc_trans/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#![feature(conservative_impl_trait)]
4141

4242
use rustc::dep_graph::WorkProduct;
43+
use syntax_pos::symbol::Symbol;
4344

4445
extern crate flate;
4546
extern crate libc;
@@ -165,6 +166,7 @@ unsafe impl Send for ModuleTranslation { }
165166
unsafe impl Sync for ModuleTranslation { }
166167

167168
pub struct CrateTranslation {
169+
pub crate_name: Symbol,
168170
pub modules: Vec<ModuleTranslation>,
169171
pub metadata_module: ModuleTranslation,
170172
pub link: middle::cstore::LinkMeta,

0 commit comments

Comments
 (0)