Skip to content

Commit 4e3dbfe

Browse files
committed
librustc: Remove structural record types from the compiler
1 parent 239e642 commit 4e3dbfe

File tree

25 files changed

+28
-371
lines changed

25 files changed

+28
-371
lines changed

src/librustc/metadata/tydecode.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -299,16 +299,6 @@ fn parse_ty(st: @mut PState, conv: conv_did) -> ty::t {
299299
let v = parse_vstore(st);
300300
return ty::mk_estr(st.tcx, v);
301301
}
302-
'R' => {
303-
assert (next(st) == '[');
304-
let mut fields: ~[ty::field] = ~[];
305-
while peek(st) != ']' {
306-
let name = st.tcx.sess.ident_of(parse_str(st, '='));
307-
fields.push(ty::field { ident: name, mt: parse_mt(st, conv) });
308-
}
309-
st.pos = st.pos + 1u;
310-
return ty::mk_rec(st.tcx, fields);
311-
}
312302
'T' => {
313303
assert (next(st) == '[');
314304
let mut params = ~[];

src/librustc/metadata/tyencode.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,6 @@ fn enc_sty(w: io::Writer, cx: @ctxt, +st: ty::sty) {
283283
enc_vstore(w, cx, v);
284284
}
285285
ty::ty_unboxed_vec(mt) => { w.write_char('U'); enc_mt(w, cx, mt); }
286-
ty::ty_rec(fields) => {
287-
w.write_str(&"R[");
288-
for fields.each |field| {
289-
w.write_str(*cx.tcx.sess.str_of(field.ident));
290-
w.write_char('=');
291-
enc_mt(w, cx, field.mt);
292-
}
293-
w.write_char(']');
294-
}
295286
ty::ty_closure(ref f) => {
296287
w.write_char('f');
297288
enc_closure_ty(w, cx, f);

src/librustc/middle/check_match.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ pub fn missing_ctor(cx: @MatchCheckCtxt,
352352
-> Option<ctor> {
353353
match ty::get(left_ty).sty {
354354
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) | ty::ty_tup(_) |
355-
ty::ty_rec(_) | ty::ty_struct(*) => {
355+
ty::ty_struct(*) => {
356356
for m.each |r| {
357357
if !is_wild(cx, r[0]) { return None; }
358358
}
@@ -449,7 +449,6 @@ pub fn missing_ctor(cx: @MatchCheckCtxt,
449449
pub fn ctor_arity(cx: @MatchCheckCtxt, ctor: ctor, ty: ty::t) -> uint {
450450
match /*bad*/copy ty::get(ty).sty {
451451
ty::ty_tup(fs) => fs.len(),
452-
ty::ty_rec(fs) => fs.len(),
453452
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) => 1u,
454453
ty::ty_enum(eid, _) => {
455454
let id = match ctor { variant(id) => id,
@@ -548,19 +547,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
548547
_ => None
549548
}
550549
}
551-
pat_rec(ref flds, _) => {
552-
let ty_flds = match /*bad*/copy ty::get(left_ty).sty {
553-
ty::ty_rec(flds) => flds,
554-
_ => fail!(~"bad type for pat_rec")
555-
};
556-
let args = vec::map(ty_flds, |ty_fld| {
557-
match flds.find(|f| f.ident == ty_fld.ident) {
558-
Some(f) => f.pat,
559-
_ => wild()
560-
}
561-
});
562-
Some(vec::append(args, vec::from_slice(r.tail())))
563-
}
550+
pat_rec(ref flds, _) => fail!(),
564551
pat_struct(_, ref flds, _) => {
565552
// Is this a struct or an enum variant?
566553
match cx.tcx.def_map.get(&pat_id) {

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,15 +1114,8 @@ pub fn field_mutbl(tcx: ty::ctxt,
11141114
f_name: ast::ident,
11151115
node_id: ast::node_id)
11161116
-> Option<ast::mutability> {
1117-
// Need to refactor so that records/class fields can be treated uniformly.
1117+
// Need to refactor so that struct/enum fields can be treated uniformly.
11181118
match /*bad*/copy ty::get(base_ty).sty {
1119-
ty::ty_rec(fields) => {
1120-
for fields.each |f| {
1121-
if f.ident == f_name {
1122-
return Some(f.mt.mutbl);
1123-
}
1124-
}
1125-
}
11261119
ty::ty_struct(did, _) => {
11271120
for ty::lookup_struct_fields(tcx, did).each |fld| {
11281121
if fld.ident == f_name {

src/librustc/middle/moves.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ pub impl VisitContext {
480480
// then `with` is consumed, otherwise it is only read
481481
let with_ty = ty::expr_ty(self.tcx, *with_expr);
482482
let with_fields = match ty::get(with_ty).sty {
483-
ty::ty_rec(ref f) => copy *f,
484483
ty::ty_struct(did, ref substs) => {
485484
ty::struct_fields(self.tcx, did, substs)
486485
}

src/librustc/middle/region.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -729,12 +729,6 @@ pub fn determine_rp_in_ty(ty: @ast::Ty,
729729
visit_mt(mt, cx, visitor);
730730
}
731731

732-
ast::ty_rec(ref fields) => {
733-
for (*fields).each |field| {
734-
visit_mt(field.node.mt, cx, visitor);
735-
}
736-
}
737-
738732
ast::ty_path(path, _) => {
739733
// type parameters are---for now, anyway---always invariant
740734
do cx.with_ambient_variance(rv_invariant) {

src/librustc/middle/trans/adt.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
/*!
1212
* # Representation of Algebraic Data Types
1313
*
14-
* This module determines how to represent enums, structs, tuples, and
15-
* (deprecated) structural records based on their monomorphized types;
16-
* it is responsible both for choosing a representation and
17-
* translating basic operations on values of those types.
14+
* This module determines how to represent enums, structs, and tuples
15+
* based on their monomorphized types; it is responsible both for
16+
* choosing a representation and translating basic operations on
17+
* values of those types.
1818
*
1919
* Note that the interface treats everything as a general case of an
2020
* enum, so structs/tuples/etc. have one pseudo-variant with
@@ -131,11 +131,6 @@ pub fn represent_type(cx: @CrateContext, t: ty::t) -> @Repr {
131131
ty::ty_tup(ref elems) => {
132132
Univariant(mk_struct(cx, *elems), NonStruct)
133133
}
134-
ty::ty_rec(ref fields) => {
135-
// XXX: Are these in the right order?
136-
Univariant(mk_struct(cx, fields.map(|f| f.mt.ty)),
137-
StructWithoutDtor)
138-
}
139134
ty::ty_struct(def_id, ref substs) => {
140135
let fields = ty::lookup_struct_fields(cx.tcx, def_id);
141136
let dt = ty::ty_dtor(cx.tcx, def_id).is_present();

src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ pub fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
639639

640640
let mut cx = cx;
641641
match /*bad*/copy ty::get(t).sty {
642-
ty::ty_rec(*) | ty::ty_struct(*) => {
642+
ty::ty_struct(*) => {
643643
let repr = adt::represent_type(cx.ccx(), t);
644644
do expr::with_field_tys(cx.tcx(), t, None) |discr, field_tys| {
645645
for vec::eachi(field_tys) |i, field_ty| {

src/librustc/middle/trans/debuginfo.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -473,33 +473,6 @@ fn add_member(cx: @mut StructCtxt,
473473
cx.total_size += size * 8;
474474
}
475475

476-
fn create_record(cx: @CrateContext, t: ty::t, fields: ~[ast::ty_field],
477-
span: span) -> @Metadata<TyDescMetadata> {
478-
let fname = filename_from_span(cx, span);
479-
let file_node = create_file(cx, fname);
480-
let scx = create_structure(file_node,
481-
cx.sess.str_of(
482-
((/*bad*/copy cx.dbg_cx).get().names)
483-
(~"rec")),
484-
line_from_span(cx.sess.codemap,
485-
span) as int);
486-
for fields.each |field| {
487-
let field_t = ty::get_field(cx.tcx, t, field.node.ident).mt.ty;
488-
let ty_md = create_ty(cx, field_t, field.node.mt.ty);
489-
let (size, align) = size_and_align_of(cx, field_t);
490-
add_member(scx, *cx.sess.str_of(field.node.ident),
491-
line_from_span(cx.sess.codemap, field.span) as int,
492-
size as int, align as int, ty_md.node);
493-
}
494-
let mdval = @Metadata {
495-
node: finish_structure(scx),
496-
data: TyDescMetadata {
497-
hash: ty::type_id(t)
498-
}
499-
};
500-
return mdval;
501-
}
502-
503476
fn create_boxed_type(cx: @CrateContext, outer: ty::t, _inner: ty::t,
504477
span: span, boxed: @Metadata<TyDescMetadata>)
505478
-> @Metadata<TyDescMetadata> {
@@ -628,16 +601,6 @@ fn create_ty(_cx: @CrateContext, _t: ty::t, _ty: @ast::Ty)
628601
mutbl: mt.mutbl}) }
629602
ty::ty_uniq(mt) { ast::ty_uniq({ty: t_to_ty(cx, mt.ty, span),
630603
mutbl: mt.mutbl}) }
631-
ty::ty_rec(fields) {
632-
let fs = ~[];
633-
for field in fields {
634-
fs.push({node: {ident: field.ident,
635-
mt: {ty: t_to_ty(cx, field.mt.ty, span),
636-
mutbl: field.mt.mutbl}},
637-
span: span});
638-
}
639-
ast::ty_rec(fs)
640-
}
641604
ty::ty_vec(mt) { ast::ty_vec({ty: t_to_ty(cx, mt.ty, span),
642605
mutbl: mt.mutbl}) }
643606
_ {
@@ -673,10 +636,6 @@ fn create_ty(_cx: @CrateContext, _t: ty::t, _ty: @ast::Ty)
673636
return create_ty(cx, t, inferred);
674637
}
675638
676-
ast::ty_rec(fields) {
677-
return create_record(cx, t, fields, ty.span);
678-
}
679-
680639
ast::ty_vec(mt) {
681640
let inner_t = ty::sequence_element_type(cx.tcx, t);
682641
let inner_ast_t = t_to_ty(cx, inner_t, mt.ty.span);

src/librustc/middle/trans/expr.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,10 +1141,6 @@ pub fn with_field_tys<R>(tcx: ty::ctxt,
11411141
node_id_opt: Option<ast::node_id>,
11421142
op: fn(int, (&[ty::field])) -> R) -> R {
11431143
match ty::get(ty).sty {
1144-
ty::ty_rec(ref fields) => {
1145-
op(0, *fields)
1146-
}
1147-
11481144
ty::ty_struct(did, ref substs) => {
11491145
op(0, struct_mutable_fields(tcx, did, substs))
11501146
}

0 commit comments

Comments
 (0)