Skip to content

Commit 749494e

Browse files
committed
trans: remove item_symbols from metadata and CrateContext.
1 parent ff3a1ce commit 749494e

File tree

9 files changed

+6
-96
lines changed

9 files changed

+6
-96
lines changed

src/librustc/middle/cstore.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ use mir::mir_map::MirMap;
3333
use session::Session;
3434
use session::config::PanicStrategy;
3535
use session::search_paths::PathKind;
36-
use util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap};
36+
use util::nodemap::{FnvHashMap, NodeSet, DefIdMap};
3737
use std::any::Any;
38-
use std::cell::RefCell;
3938
use std::rc::Rc;
4039
use std::path::PathBuf;
4140
use syntax::ast;
@@ -174,7 +173,6 @@ pub trait CrateStore<'tcx> : Any {
174173
fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
175174
-> ty::GenericPredicates<'tcx>;
176175
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>;
177-
fn item_symbol(&self, def: DefId) -> String;
178176
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef<'tcx>;
179177
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>;
180178
fn method_arg_names(&self, did: DefId) -> Vec<String>;
@@ -276,7 +274,6 @@ pub trait CrateStore<'tcx> : Any {
276274
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum>;
277275
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
278276
reexports: &def::ExportMap,
279-
item_symbols: &RefCell<NodeMap<String>>,
280277
link_meta: &LinkMeta,
281278
reachable: &NodeSet,
282279
mir_map: &MirMap<'tcx>,
@@ -354,7 +351,6 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
354351
fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
355352
-> ty::GenericPredicates<'tcx> { bug!("item_super_predicates") }
356353
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { bug!("item_attrs") }
357-
fn item_symbol(&self, def: DefId) -> String { bug!("item_symbol") }
358354
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef<'tcx>
359355
{ bug!("trait_def") }
360356
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>
@@ -478,7 +474,6 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
478474
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum> { None }
479475
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
480476
reexports: &def::ExportMap,
481-
item_symbols: &RefCell<NodeMap<String>>,
482477
link_meta: &LinkMeta,
483478
reachable: &NodeSet,
484479
mir_map: &MirMap<'tcx>,

src/librustc_metadata/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub const tag_items_data_item_family: usize = 0x24;
3333

3434
pub const tag_items_data_item_type: usize = 0x25;
3535

36-
pub const tag_items_data_item_symbol: usize = 0x26;
36+
// GAP 0x26
3737

3838
pub const tag_items_data_item_variant: usize = 0x27;
3939

src/librustc_metadata/csearch.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc::hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX};
2323
use rustc::hir::map as hir_map;
2424
use rustc::mir::repr::Mir;
2525
use rustc::mir::mir_map::MirMap;
26-
use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap};
26+
use rustc::util::nodemap::{FnvHashMap, NodeSet, DefIdMap};
2727
use rustc::session::config::PanicStrategy;
2828

2929
use std::cell::RefCell;
@@ -105,12 +105,6 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
105105
decoder::get_item_attrs(&cdata, def_id.index)
106106
}
107107

108-
fn item_symbol(&self, def: DefId) -> String
109-
{
110-
let cdata = self.get_crate_data(def.krate);
111-
decoder::get_symbol(&cdata, def.index)
112-
}
113-
114108
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::TraitDef<'tcx>
115109
{
116110
let cdata = self.get_crate_data(def.krate);
@@ -517,7 +511,6 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
517511

518512
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
519513
reexports: &def::ExportMap,
520-
item_symbols: &RefCell<NodeMap<String>>,
521514
link_meta: &LinkMeta,
522515
reachable: &NodeSet,
523516
mir_map: &MirMap<'tcx>,
@@ -527,7 +520,6 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
527520
diag: tcx.sess.diagnostic(),
528521
tcx: tcx,
529522
reexports: reexports,
530-
item_symbols: item_symbols,
531523
link_meta: link_meta,
532524
cstore: self,
533525
reachable: reachable,

src/librustc_metadata/decoder.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,6 @@ fn item_sort(item: rbml::Doc) -> Option<char> {
186186
})
187187
}
188188

189-
fn item_symbol(item: rbml::Doc) -> String {
190-
reader::get_doc(item, tag_items_data_item_symbol).as_str().to_string()
191-
}
192-
193189
fn translated_def_id(cdata: Cmd, d: rbml::Doc) -> DefId {
194190
let id = reader::doc_as_u64(d);
195191
let index = DefIndex::new((id & 0xFFFF_FFFF) as usize);
@@ -609,10 +605,6 @@ pub fn get_impl_trait<'a, 'tcx>(cdata: Cmd,
609605
}
610606
}
611607

612-
pub fn get_symbol(cdata: Cmd, id: DefIndex) -> String {
613-
return item_symbol(cdata.lookup_item(id));
614-
}
615-
616608
/// Iterates over the language items in the given crate.
617609
pub fn each_lang_item<F>(cdata: Cmd, mut f: F) -> bool where
618610
F: FnMut(DefIndex, usize) -> bool,

src/librustc_metadata/encoder.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use rustc::ty::util::IntTypeExt;
3333
use rustc::hir::svh::Svh;
3434
use rustc::mir::mir_map::MirMap;
3535
use rustc::session::config::{self, PanicStrategy};
36-
use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet};
36+
use rustc::util::nodemap::{FnvHashMap, NodeSet};
3737

3838
use rustc_serialize::Encodable;
3939
use std::cell::RefCell;
@@ -58,7 +58,6 @@ pub struct EncodeContext<'a, 'tcx: 'a> {
5858
pub diag: &'a Handler,
5959
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
6060
pub reexports: &'a def::ExportMap,
61-
pub item_symbols: &'a RefCell<NodeMap<String>>,
6261
pub link_meta: &'a LinkMeta,
6362
pub cstore: &'a cstore::CStore,
6463
pub type_abbrevs: tyencode::abbrev_map<'tcx>,
@@ -204,20 +203,6 @@ fn encode_region(ecx: &EncodeContext,
204203
rbml_w.end_tag();
205204
}
206205

207-
fn encode_symbol(ecx: &EncodeContext,
208-
rbml_w: &mut Encoder,
209-
id: NodeId) {
210-
match ecx.item_symbols.borrow().get(&id) {
211-
Some(x) => {
212-
debug!("encode_symbol(id={}, str={})", id, *x);
213-
rbml_w.wr_tagged_str(tag_items_data_item_symbol, x);
214-
}
215-
None => {
216-
bug!("encode_symbol: id not found {}", id);
217-
}
218-
}
219-
}
220-
221206
fn encode_disr_val(_: &EncodeContext,
222207
rbml_w: &mut Encoder,
223208
disr_val: ty::Disr) {
@@ -512,10 +497,6 @@ fn encode_info_for_struct_ctor<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
512497
encode_name(rbml_w, name);
513498
encode_parent_item(rbml_w, ecx.tcx.map.local_def_id(struct_id));
514499

515-
if ecx.item_symbols.borrow().contains_key(&ctor_id) {
516-
encode_symbol(ecx, rbml_w, ctor_id);
517-
}
518-
519500
let stab = ecx.tcx.lookup_stability(ecx.tcx.map.local_def_id(ctor_id));
520501
let depr= ecx.tcx.lookup_deprecation(ecx.tcx.map.local_def_id(ctor_id));
521502
encode_stability(rbml_w, stab);
@@ -704,10 +685,6 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
704685
}
705686
encode_constness(rbml_w, sig.constness);
706687
encode_defaultness(rbml_w, impl_item.defaultness);
707-
if !any_types {
708-
let m_id = ecx.local_id(m.def_id);
709-
encode_symbol(ecx, rbml_w, m_id);
710-
}
711688
encode_method_argument_names(rbml_w, &sig.decl);
712689
}
713690
}
@@ -885,7 +862,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
885862
encode_family(rbml_w, 'c');
886863
}
887864
encode_bounds_and_type_for_item(rbml_w, ecx, index, item.id);
888-
encode_symbol(ecx, rbml_w, item.id);
889865
encode_name(rbml_w, item.name);
890866
encode_visibility(rbml_w, vis);
891867
encode_stability(rbml_w, stab);
@@ -922,9 +898,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
922898
encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(item));
923899
encode_mir(ecx, rbml_w, item.id);
924900
}
925-
if tps_len == 0 {
926-
encode_symbol(ecx, rbml_w, item.id);
927-
}
928901
encode_constness(rbml_w, constness);
929902
encode_visibility(rbml_w, vis);
930903
encode_stability(rbml_w, stab);
@@ -1355,8 +1328,6 @@ fn encode_info_for_foreign_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
13551328
if abi == Abi::RustIntrinsic || abi == Abi::PlatformIntrinsic {
13561329
encode_inlined_item(ecx, rbml_w, InlinedItemRef::Foreign(nitem));
13571330
encode_mir(ecx, rbml_w, nitem.id);
1358-
} else {
1359-
encode_symbol(ecx, rbml_w, nitem.id);
13601331
}
13611332
encode_attributes(rbml_w, &nitem.attrs);
13621333
let stab = ecx.tcx.lookup_stability(ecx.tcx.map.local_def_id(nitem.id));
@@ -1377,7 +1348,6 @@ fn encode_info_for_foreign_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
13771348
let depr = ecx.tcx.lookup_deprecation(ecx.tcx.map.local_def_id(nitem.id));
13781349
encode_stability(rbml_w, stab);
13791350
encode_deprecation(rbml_w, depr);
1380-
encode_symbol(ecx, rbml_w, nitem.id);
13811351
encode_name(rbml_w, nitem.name);
13821352
}
13831353
}

src/librustc_trans/base.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ use llvm;
3838
use rustc::cfg;
3939
use rustc::hir::def_id::DefId;
4040
use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem};
41-
use middle::weak_lang_items;
4241
use rustc::hir::pat_util::simple_name;
4342
use rustc::ty::subst::{self, Substs};
4443
use rustc::traits;
@@ -2337,15 +2336,6 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) {
23372336
set_global_section(ccx, g, item);
23382337
update_linkage(ccx, g, Some(item.id), OriginalTranslation);
23392338
}
2340-
hir::ItemForeignMod(ref m) => {
2341-
if m.abi == Abi::RustIntrinsic || m.abi == Abi::PlatformIntrinsic {
2342-
return;
2343-
}
2344-
for fi in &m.items {
2345-
let lname = imported_name(fi.name, &fi.attrs).to_string();
2346-
ccx.item_symbols().borrow_mut().insert(fi.id, lname);
2347-
}
2348-
}
23492339
_ => {}
23502340
}
23512341
}
@@ -2430,16 +2420,6 @@ pub fn create_entry_wrapper(ccx: &CrateContext, sp: Span, main_llfn: ValueRef) {
24302420
}
24312421
}
24322422

2433-
pub fn imported_name(name: ast::Name, attrs: &[ast::Attribute]) -> InternedString {
2434-
match attr::first_attr_value_str_by_name(attrs, "link_name") {
2435-
Some(ln) => ln.clone(),
2436-
None => match weak_lang_items::link_name(attrs) {
2437-
Some(name) => name,
2438-
None => name.as_str(),
2439-
}
2440-
}
2441-
}
2442-
24432423
fn contains_null(s: &str) -> bool {
24442424
s.bytes().any(|b| b == 0)
24452425
}
@@ -2463,7 +2443,6 @@ pub fn write_metadata<'a, 'tcx>(cx: &SharedCrateContext<'a, 'tcx>,
24632443
let cstore = &cx.tcx().sess.cstore;
24642444
let metadata = cstore.encode_metadata(cx.tcx(),
24652445
cx.export_map(),
2466-
cx.item_symbols(),
24672446
cx.link_meta(),
24682447
reachable,
24692448
mir_map,

src/librustc_trans/callee.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,11 +575,6 @@ fn get_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
575575
llfn
576576
};
577577

578-
// Always insert into item_symbols, in case this item is exported.
579-
if let Some(id) = local_item {
580-
ccx.item_symbols().borrow_mut().insert(id, sym);
581-
}
582-
583578
ccx.instances().borrow_mut().insert(instance, llfn);
584579

585580
immediate_rvalue(llfn, fn_ptr_ty)

src/librustc_trans/consts.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,13 +1032,10 @@ pub fn get_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, def_id: DefId)
10321032

10331033
// Create the global before evaluating the initializer;
10341034
// this is necessary to allow recursive statics.
1035-
let g = declare::define_global(ccx, &sym, llty).unwrap_or_else(|| {
1035+
declare::define_global(ccx, &sym, llty).unwrap_or_else(|| {
10361036
ccx.sess().span_fatal(span,
10371037
&format!("symbol `{}` is already defined", sym))
1038-
});
1039-
1040-
ccx.item_symbols().borrow_mut().insert(id, sym);
1041-
g
1038+
})
10421039
}
10431040

10441041
hir_map::NodeForeignItem(&hir::ForeignItem {

src/librustc_trans/context.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ pub struct SharedCrateContext<'a, 'tcx: 'a> {
7070

7171
export_map: ExportMap,
7272
reachable: NodeSet,
73-
item_symbols: RefCell<NodeMap<String>>,
7473
link_meta: LinkMeta,
7574
symbol_hasher: RefCell<Sha256>,
7675
tcx: TyCtxt<'a, 'tcx, 'tcx>,
@@ -394,7 +393,6 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
394393
metadata_llcx: metadata_llcx,
395394
export_map: export_map,
396395
reachable: reachable,
397-
item_symbols: RefCell::new(NodeMap()),
398396
link_meta: link_meta,
399397
symbol_hasher: RefCell::new(symbol_hasher),
400398
tcx: tcx,
@@ -438,10 +436,6 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
438436
&self.reachable
439437
}
440438

441-
pub fn item_symbols<'a>(&'a self) -> &'a RefCell<NodeMap<String>> {
442-
&self.item_symbols
443-
}
444-
445439
pub fn trait_cache(&self) -> &RefCell<DepTrackingMap<TraitSelectionCache<'tcx>>> {
446440
&self.trait_cache
447441
}
@@ -698,10 +692,6 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
698692
&self.shared.reachable
699693
}
700694

701-
pub fn item_symbols<'a>(&'a self) -> &'a RefCell<NodeMap<String>> {
702-
&self.shared.item_symbols
703-
}
704-
705695
pub fn link_meta<'a>(&'a self) -> &'a LinkMeta {
706696
&self.shared.link_meta
707697
}

0 commit comments

Comments
 (0)