Skip to content

Commit 53f54dd

Browse files
committed
librustc: Remove def_ids from types.
1 parent 04df19c commit 53f54dd

File tree

5 files changed

+8
-50
lines changed

5 files changed

+8
-50
lines changed

src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,7 @@ fn doc_transformed_self_ty(doc: ebml::Doc,
249249
250250
pub fn item_type(item_id: ast::def_id, item: ebml::Doc,
251251
tcx: ty::ctxt, cdata: cmd) -> ty::t {
252-
let t = doc_type(item, tcx, cdata);
253-
if family_names_type(item_family(item)) {
254-
ty::mk_with_id(tcx, t, item_id)
255-
} else {
256-
t
257-
}
252+
doc_type(item, tcx, cdata)
258253
}
259254
260255
fn doc_trait_ref(doc: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::TraitRef {

src/librustc/metadata/tydecode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,9 @@ fn parse_ty(st: @mut PState, conv: conv_did) -> ty::t {
381381
}
382382
}
383383
'"' => {
384-
let def = parse_def(st, TypeWithId, conv);
384+
let _ = parse_def(st, TypeWithId, conv);
385385
let inner = parse_ty(st, conv);
386-
ty::mk_with_id(st.tcx, inner, def)
386+
inner
387387
}
388388
'B' => ty::mk_opaque_box(st.tcx),
389389
'a' => {

src/librustc/metadata/tyencode.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,6 @@ pub fn enc_ty(w: @io::Writer, cx: @ctxt, t: ty::t) {
7878
Some(a) => { w.write_str(*a.s); return; }
7979
None => {
8080
let pos = w.tell();
81-
match ty::type_def_id(t) {
82-
Some(def_id) => {
83-
// Do not emit node ids that map to unexported names. Those
84-
// are not helpful.
85-
if def_id.crate != local_crate ||
86-
(cx.reachable)(def_id.node) {
87-
w.write_char('"');
88-
w.write_str((cx.ds)(def_id));
89-
w.write_char('|');
90-
}
91-
}
92-
_ => {}
93-
}
9481
enc_sty(w, cx, /*bad*/copy ty::get(t).sty);
9582
let end = w.tell();
9683
let len = end - pos;

src/librustc/middle/ty.rs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ impl to_bytes::IterBytes for creader_cache_key {
133133

134134
struct intern_key {
135135
sty: *sty,
136-
o_def_id: Option<ast::def_id>
137136
}
138137

139138
// NB: Do not replace this with #[deriving(Eq)]. The automatically-derived
@@ -142,7 +141,7 @@ struct intern_key {
142141
impl cmp::Eq for intern_key {
143142
fn eq(&self, other: &intern_key) -> bool {
144143
unsafe {
145-
*self.sty == *other.sty && self.o_def_id == other.o_def_id
144+
*self.sty == *other.sty
146145
}
147146
}
148147
fn ne(&self, other: &intern_key) -> bool {
@@ -153,7 +152,7 @@ impl cmp::Eq for intern_key {
153152
impl to_bytes::IterBytes for intern_key {
154153
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
155154
unsafe {
156-
to_bytes::iter_bytes_2(&*self.sty, &self.o_def_id, lsb0, f);
155+
(*self.sty).iter_bytes(lsb0, f);
157156
}
158157
}
159158
}
@@ -326,7 +325,6 @@ pub struct t_box_ {
326325
sty: sty,
327326
id: uint,
328327
flags: uint,
329-
o_def_id: Option<ast::def_id>
330328
}
331329

332330
// To reduce refcounting cost, we're representing types as unsafe pointers
@@ -359,7 +357,6 @@ pub fn type_needs_infer(t: t) -> bool {
359357
pub fn type_has_regions(t: t) -> bool {
360358
tbox_has_flag(get(t), has_regions)
361359
}
362-
pub fn type_def_id(t: t) -> Option<ast::def_id> { get(t).o_def_id }
363360
pub fn type_id(t: t) -> uint { get(t).id }
364361

365362
#[deriving(Eq)]
@@ -516,7 +513,6 @@ pub struct substs {
516513
mod primitives {
517514
use super::{sty, t_box_};
518515

519-
use core::option::None;
520516
use syntax::ast;
521517

522518
macro_rules! def_prim_ty(
@@ -525,7 +521,6 @@ mod primitives {
525521
sty: $sty,
526522
id: $id,
527523
flags: 0,
528-
o_def_id: None,
529524
};
530525
)
531526
)
@@ -551,14 +546,12 @@ mod primitives {
551546
sty: super::ty_bot,
552547
id: 16,
553548
flags: super::has_ty_bot as uint,
554-
o_def_id: None,
555549
};
556550

557551
pub static TY_ERR: t_box_ = t_box_ {
558552
sty: super::ty_err,
559553
id: 17,
560554
flags: super::has_ty_err as uint,
561-
o_def_id: None,
562555
};
563556

564557
pub static LAST_PRIMITIVE_ID: uint = 18;
@@ -945,13 +938,11 @@ pub fn mk_ctxt(s: session::Session,
945938
}
946939
}
947940

948-
949941
// Type constructors
950-
fn mk_t(cx: ctxt, +st: sty) -> t { mk_t_with_id(cx, st, None) }
951942

952943
// Interns a type/name combination, stores the resulting box in cx.interner,
953944
// and returns the box as cast to an unsafe ptr (see comments for t above).
954-
fn mk_t_with_id(cx: ctxt, +st: sty, o_def_id: Option<ast::def_id>) -> t {
945+
fn mk_t(cx: ctxt, +st: sty) -> t {
955946
// Check for primitive types.
956947
match st {
957948
ty_nil => return mk_nil(cx),
@@ -963,7 +954,7 @@ fn mk_t_with_id(cx: ctxt, +st: sty, o_def_id: Option<ast::def_id>) -> t {
963954
_ => {}
964955
};
965956

966-
let key = intern_key { sty: to_unsafe_ptr(&st), o_def_id: o_def_id };
957+
let key = intern_key { sty: to_unsafe_ptr(&st) };
967958
match cx.interner.find(&key) {
968959
Some(t) => unsafe { return cast::transmute(&t.sty); },
969960
_ => ()
@@ -1039,14 +1030,12 @@ fn mk_t_with_id(cx: ctxt, +st: sty, o_def_id: Option<ast::def_id>) -> t {
10391030
sty: st,
10401031
id: *cx.next_id,
10411032
flags: flags,
1042-
o_def_id: o_def_id
10431033
};
10441034

10451035
let sty_ptr = to_unsafe_ptr(&t.sty);
10461036

10471037
let key = intern_key {
10481038
sty: sty_ptr,
1049-
o_def_id: o_def_id
10501039
};
10511040

10521041
cx.interner.insert(key, t);
@@ -1263,10 +1252,6 @@ pub fn mk_opaque_closure_ptr(cx: ctxt, sigil: ast::Sigil) -> t {
12631252

12641253
pub fn mk_opaque_box(cx: ctxt) -> t { mk_t(cx, ty_opaque_box) }
12651254

1266-
pub fn mk_with_id(cx: ctxt, base: t, def_id: ast::def_id) -> t {
1267-
mk_t_with_id(cx, /*bad*/copy get(base).sty, Some(def_id))
1268-
}
1269-
12701255
// Converts s to its machine type equivalent
12711256
pub fn mach_sty(cfg: @session::config, t: t) -> sty {
12721257
match get(t).sty {

src/librustc/middle/typeck/collect.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,16 +1085,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: @ast::item)
10851085
let region_parameterization =
10861086
RegionParameterization::from_variance_and_generics(rp, generics);
10871087
let tpt = {
1088-
let ty = {
1089-
let t0 = ccx.to_ty(&type_rscope(region_parameterization), t);
1090-
// Do not associate a def id with a named, parameterized type
1091-
// like "foo<X>". This is because otherwise ty_to_str will
1092-
// print the name as merely "foo", as it has no way to
1093-
// reconstruct the value of X.
1094-
if generics.is_parameterized() { t0 } else {
1095-
ty::mk_with_id(tcx, t0, def_id)
1096-
}
1097-
};
1088+
let ty = ccx.to_ty(&type_rscope(region_parameterization), t);
10981089
ty_param_bounds_and_ty {
10991090
generics: ty_generics(ccx, rp, generics, 0),
11001091
ty: ty

0 commit comments

Comments
 (0)