Skip to content

Commit 04464db

Browse files
committed
trans: remove item_symbols from metadata and CrateContext.
1 parent b03bde9 commit 04464db

File tree

9 files changed

+6
-97
lines changed

9 files changed

+6
-97
lines changed

src/librustc/middle/cstore.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ use mir::mir_map::MirMap;
3434
use session::Session;
3535
use session::config::PanicStrategy;
3636
use session::search_paths::PathKind;
37-
use util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap};
38-
use std::cell::RefCell;
37+
use util::nodemap::{FnvHashMap, NodeSet, DefIdMap};
3938
use std::rc::Rc;
4039
use std::path::PathBuf;
4140
use syntax::ast;
@@ -169,7 +168,6 @@ pub trait CrateStore<'tcx> {
169168
fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
170169
-> ty::GenericPredicates<'tcx>;
171170
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>;
172-
fn item_symbol(&self, def: DefId) -> String;
173171
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef<'tcx>;
174172
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>;
175173
fn method_arg_names(&self, did: DefId) -> Vec<String>;
@@ -275,7 +273,6 @@ pub trait CrateStore<'tcx> {
275273
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum>;
276274
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
277275
reexports: &def::ExportMap,
278-
item_symbols: &RefCell<NodeMap<String>>,
279276
link_meta: &LinkMeta,
280277
reachable: &NodeSet,
281278
mir_map: &MirMap<'tcx>,
@@ -353,7 +350,6 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
353350
fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
354351
-> ty::GenericPredicates<'tcx> { bug!("item_super_predicates") }
355352
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { bug!("item_attrs") }
356-
fn item_symbol(&self, def: DefId) -> String { bug!("item_symbol") }
357353
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef<'tcx>
358354
{ bug!("trait_def") }
359355
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>
@@ -483,7 +479,6 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
483479
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum> { None }
484480
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
485481
reexports: &def::ExportMap,
486-
item_symbols: &RefCell<NodeMap<String>>,
487482
link_meta: &LinkMeta,
488483
reachable: &NodeSet,
489484
mir_map: &MirMap<'tcx>,

src/librustc_metadata/common.rs

+1-1
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

+1-10
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use rustc::hir::map as hir_map;
2525
use rustc::hir::map::DefKey;
2626
use rustc::mir::repr::Mir;
2727
use rustc::mir::mir_map::MirMap;
28-
use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap};
28+
use rustc::util::nodemap::{FnvHashMap, NodeSet, DefIdMap};
2929
use rustc::session::config::PanicStrategy;
3030

3131
use std::cell::RefCell;
@@ -115,13 +115,6 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
115115
decoder::get_item_attrs(&cdata, def_id.index)
116116
}
117117

118-
fn item_symbol(&self, def: DefId) -> String
119-
{
120-
self.dep_graph.read(DepNode::MetaData(def));
121-
let cdata = self.get_crate_data(def.krate);
122-
decoder::get_symbol(&cdata, def.index)
123-
}
124-
125118
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::TraitDef<'tcx>
126119
{
127120
self.dep_graph.read(DepNode::MetaData(def));
@@ -569,7 +562,6 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
569562

570563
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
571564
reexports: &def::ExportMap,
572-
item_symbols: &RefCell<NodeMap<String>>,
573565
link_meta: &LinkMeta,
574566
reachable: &NodeSet,
575567
mir_map: &MirMap<'tcx>,
@@ -579,7 +571,6 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
579571
diag: tcx.sess.diagnostic(),
580572
tcx: tcx,
581573
reexports: reexports,
582-
item_symbols: item_symbols,
583574
link_meta: link_meta,
584575
cstore: self,
585576
reachable: reachable,

src/librustc_metadata/decoder.rs

-8
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,6 @@ fn item_sort(item: rbml::Doc) -> Option<char> {
213213
})
214214
}
215215

216-
fn item_symbol(item: rbml::Doc) -> String {
217-
reader::get_doc(item, tag_items_data_item_symbol).as_str().to_string()
218-
}
219-
220216
fn untranslated_def_id(d: rbml::Doc) -> DefId {
221217
let id = reader::doc_as_u64(d);
222218
let index = DefIndex::new((id & 0xFFFF_FFFF) as usize);
@@ -640,10 +636,6 @@ pub fn get_impl_trait<'a, 'tcx>(cdata: Cmd,
640636
}
641637
}
642638

643-
pub fn get_symbol(cdata: Cmd, id: DefIndex) -> String {
644-
return item_symbol(cdata.lookup_item(id));
645-
}
646-
647639
/// Iterates over the language items in the given crate.
648640
pub fn each_lang_item<F>(cdata: Cmd, mut f: F) -> bool where
649641
F: FnMut(DefIndex, usize) -> bool,

src/librustc_metadata/encoder.rs

+1-31
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use rustc::ty::util::IntTypeExt;
3434
use rustc::hir::svh::Svh;
3535
use rustc::mir::mir_map::MirMap;
3636
use rustc::session::config::{self, PanicStrategy};
37-
use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet};
37+
use rustc::util::nodemap::{FnvHashMap, NodeSet};
3838

3939
use rustc_serialize::Encodable;
4040
use std::cell::RefCell;
@@ -59,7 +59,6 @@ pub struct EncodeContext<'a, 'tcx: 'a> {
5959
pub diag: &'a Handler,
6060
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
6161
pub reexports: &'a def::ExportMap,
62-
pub item_symbols: &'a RefCell<NodeMap<String>>,
6362
pub link_meta: &'a LinkMeta,
6463
pub cstore: &'a cstore::CStore,
6564
pub type_abbrevs: tyencode::abbrev_map<'tcx>,
@@ -213,20 +212,6 @@ fn encode_region(ecx: &EncodeContext,
213212
rbml_w.end_tag();
214213
}
215214

216-
fn encode_symbol(ecx: &EncodeContext,
217-
rbml_w: &mut Encoder,
218-
id: NodeId) {
219-
match ecx.item_symbols.borrow().get(&id) {
220-
Some(x) => {
221-
debug!("encode_symbol(id={}, str={})", id, *x);
222-
rbml_w.wr_tagged_str(tag_items_data_item_symbol, x);
223-
}
224-
None => {
225-
bug!("encode_symbol: id not found {}", id);
226-
}
227-
}
228-
}
229-
230215
fn encode_disr_val(_: &EncodeContext,
231216
rbml_w: &mut Encoder,
232217
disr_val: ty::Disr) {
@@ -518,10 +503,6 @@ fn encode_info_for_struct_ctor<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
518503
encode_name(rbml_w, name);
519504
encode_parent_item(rbml_w, ecx.tcx.map.local_def_id(struct_id));
520505

521-
if ecx.item_symbols.borrow().contains_key(&ctor_id) {
522-
encode_symbol(ecx, rbml_w, ctor_id);
523-
}
524-
525506
let stab = ecx.tcx.lookup_stability(ecx.tcx.map.local_def_id(ctor_id));
526507
let depr= ecx.tcx.lookup_deprecation(ecx.tcx.map.local_def_id(ctor_id));
527508
encode_stability(rbml_w, stab);
@@ -710,10 +691,6 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
710691
}
711692
encode_constness(rbml_w, sig.constness);
712693
encode_defaultness(rbml_w, impl_item.defaultness);
713-
if !any_types {
714-
let m_id = ecx.local_id(m.def_id);
715-
encode_symbol(ecx, rbml_w, m_id);
716-
}
717694
encode_method_argument_names(rbml_w, &sig.decl);
718695
}
719696
}
@@ -894,7 +871,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
894871
encode_family(rbml_w, 'c');
895872
}
896873
encode_bounds_and_type_for_item(rbml_w, ecx, index, item.id);
897-
encode_symbol(ecx, rbml_w, item.id);
898874
encode_name(rbml_w, item.name);
899875
encode_visibility(rbml_w, vis);
900876
encode_stability(rbml_w, stab);
@@ -931,9 +907,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
931907
encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(item));
932908
encode_mir(ecx, rbml_w, item.id);
933909
}
934-
if tps_len == 0 {
935-
encode_symbol(ecx, rbml_w, item.id);
936-
}
937910
encode_constness(rbml_w, constness);
938911
encode_visibility(rbml_w, vis);
939912
encode_stability(rbml_w, stab);
@@ -1365,8 +1338,6 @@ fn encode_info_for_foreign_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
13651338
if abi == Abi::RustIntrinsic || abi == Abi::PlatformIntrinsic {
13661339
encode_inlined_item(ecx, rbml_w, InlinedItemRef::Foreign(nitem));
13671340
encode_mir(ecx, rbml_w, nitem.id);
1368-
} else {
1369-
encode_symbol(ecx, rbml_w, nitem.id);
13701341
}
13711342
encode_attributes(rbml_w, &nitem.attrs);
13721343
let stab = ecx.tcx.lookup_stability(ecx.tcx.map.local_def_id(nitem.id));
@@ -1387,7 +1358,6 @@ fn encode_info_for_foreign_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
13871358
let depr = ecx.tcx.lookup_deprecation(ecx.tcx.map.local_def_id(nitem.id));
13881359
encode_stability(rbml_w, stab);
13891360
encode_deprecation(rbml_w, depr);
1390-
encode_symbol(ecx, rbml_w, nitem.id);
13911361
encode_name(rbml_w, nitem.name);
13921362
}
13931363
}

src/librustc_trans/base.rs

-21
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;
@@ -2345,15 +2344,6 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) {
23452344
set_global_section(ccx, g, item);
23462345
update_linkage(ccx, g, Some(item.id), OriginalTranslation);
23472346
}
2348-
hir::ItemForeignMod(ref m) => {
2349-
if m.abi == Abi::RustIntrinsic || m.abi == Abi::PlatformIntrinsic {
2350-
return;
2351-
}
2352-
for fi in &m.items {
2353-
let lname = imported_name(fi.name, &fi.attrs).to_string();
2354-
ccx.item_symbols().borrow_mut().insert(fi.id, lname);
2355-
}
2356-
}
23572347
_ => {}
23582348
}
23592349
}
@@ -2438,16 +2428,6 @@ pub fn create_entry_wrapper(ccx: &CrateContext, sp: Span, main_llfn: ValueRef) {
24382428
}
24392429
}
24402430

2441-
pub fn imported_name(name: ast::Name, attrs: &[ast::Attribute]) -> InternedString {
2442-
match attr::first_attr_value_str_by_name(attrs, "link_name") {
2443-
Some(ln) => ln.clone(),
2444-
None => match weak_lang_items::link_name(attrs) {
2445-
Some(name) => name,
2446-
None => name.as_str(),
2447-
}
2448-
}
2449-
}
2450-
24512431
fn contains_null(s: &str) -> bool {
24522432
s.bytes().any(|b| b == 0)
24532433
}
@@ -2471,7 +2451,6 @@ pub fn write_metadata<'a, 'tcx>(cx: &SharedCrateContext<'a, 'tcx>,
24712451
let cstore = &cx.tcx().sess.cstore;
24722452
let metadata = cstore.encode_metadata(cx.tcx(),
24732453
cx.export_map(),
2474-
cx.item_symbols(),
24752454
cx.link_meta(),
24762455
reachable,
24772456
mir_map,

src/librustc_trans/callee.rs

-5
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

+2-5
Original file line numberDiff line numberDiff line change
@@ -1033,13 +1033,10 @@ pub fn get_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, def_id: DefId)
10331033

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

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

src/librustc_trans/context.rs

-10
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ pub struct SharedCrateContext<'a, 'tcx: 'a> {
7171

7272
export_map: ExportMap,
7373
reachable: NodeSet,
74-
item_symbols: RefCell<NodeMap<String>>,
7574
link_meta: LinkMeta,
7675
symbol_hasher: RefCell<Sha256>,
7776
tcx: TyCtxt<'a, 'tcx, 'tcx>,
@@ -395,7 +394,6 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
395394
metadata_llcx: metadata_llcx,
396395
export_map: export_map,
397396
reachable: reachable,
398-
item_symbols: RefCell::new(NodeMap()),
399397
link_meta: link_meta,
400398
symbol_hasher: RefCell::new(symbol_hasher),
401399
tcx: tcx,
@@ -439,10 +437,6 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
439437
&self.reachable
440438
}
441439

442-
pub fn item_symbols<'a>(&'a self) -> &'a RefCell<NodeMap<String>> {
443-
&self.item_symbols
444-
}
445-
446440
pub fn trait_cache(&self) -> &RefCell<DepTrackingMap<TraitSelectionCache<'tcx>>> {
447441
&self.trait_cache
448442
}
@@ -720,10 +714,6 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
720714
&self.shared.reachable
721715
}
722716

723-
pub fn item_symbols<'a>(&'a self) -> &'a RefCell<NodeMap<String>> {
724-
&self.shared.item_symbols
725-
}
726-
727717
pub fn link_meta<'a>(&'a self) -> &'a LinkMeta {
728718
&self.shared.link_meta
729719
}

0 commit comments

Comments
 (0)