Skip to content

Commit 38e8422

Browse files
committed
rustc: Remove all uses of plain_ty() and friends from outside of ty.rs
1 parent ac62488 commit 38e8422

File tree

5 files changed

+136
-165
lines changed

5 files changed

+136
-165
lines changed

src/comp/middle/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ fn encode_info_for_native_item(@trans.crate_ctxt cx, &ebml.writer ebml_w,
456456
case (ast.native_item_ty(_, ?did)) {
457457
encode_def_id(ebml_w, did);
458458
encode_kind(ebml_w, 'T' as u8);
459-
encode_type(ebml_w, ty.plain_ty(ty.ty_native));
459+
encode_type(ebml_w, ty.mk_native());
460460
}
461461
case (ast.native_item_fn(_, _, _, ?tps, ?did, ?ann)) {
462462
encode_def_id(ebml_w, did);

src/comp/middle/trans.rs

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import back.abi;
2121
import pretty.pprust;
2222

2323
import middle.ty.pat_ty;
24-
import middle.ty.plain_ty;
2524

2625
import util.common;
2726
import util.common.istr;
@@ -639,7 +638,7 @@ fn type_of_fn_full(@crate_ctxt cx,
639638
vec(T_fn_pair(cx.tn,
640639
type_of_fn_full(cx, ast.proto_fn, none[TypeRef],
641640
vec(rec(mode=ast.val, ty=output)),
642-
plain_ty(ty.ty_nil), 0u)));
641+
ty.mk_nil(), 0u)));
643642
}
644643

645644
// ... then explicit args.
@@ -1150,7 +1149,7 @@ fn simplify_type(@ty.t typ) -> @ty.t {
11501149
fn simplifier(@ty.t typ) -> @ty.t {
11511150
alt (typ.struct) {
11521151
case (ty.ty_box(_)) {
1153-
ret ty.plain_box_ty(ty.plain_ty(ty.ty_nil), ast.imm);
1152+
ret ty.mk_imm_box(ty.mk_nil());
11541153
}
11551154
case (_) { ret typ; }
11561155
}
@@ -1187,7 +1186,7 @@ fn static_size_of_tag(@crate_ctxt cx, @ty.t t) -> uint {
11871186
auto max_size = 0u;
11881187
auto variants = tag_variants(cx, tid);
11891188
for (variant_info variant in variants) {
1190-
auto tup_ty = simplify_type(ty.plain_tup_ty(variant.args));
1189+
auto tup_ty = simplify_type(ty.mk_imm_tup(variant.args));
11911190

11921191
// Perform any type parameter substitutions.
11931192
tup_ty = ty.bind_params_in_type(tup_ty);
@@ -1403,7 +1402,7 @@ fn GEP_tup_like(@block_ctxt cx, @ty.t t,
14031402
// flattened the incoming structure.
14041403

14051404
auto s = split_type(t, ixs, 0u);
1406-
auto prefix_ty = ty.plain_tup_ty(s.prefix);
1405+
auto prefix_ty = ty.mk_imm_tup(s.prefix);
14071406
auto bcx = cx;
14081407
auto sz = size_of(bcx, prefix_ty);
14091408
bcx = sz.bcx;
@@ -1434,7 +1433,7 @@ fn GEP_tag(@block_ctxt cx,
14341433
// Synthesize a tuple type so that GEP_tup_like() can work its magic.
14351434
// Separately, store the type of the element we're interested in.
14361435
auto arg_tys = variant.args;
1437-
auto elem_ty = ty.plain_ty(ty.ty_nil); // typestate infelicity
1436+
auto elem_ty = ty.mk_nil(); // typestate infelicity
14381437
auto i = 0;
14391438
let vec[@ty.t] true_arg_tys = vec();
14401439
for (@ty.t aty in arg_tys) {
@@ -1448,7 +1447,7 @@ fn GEP_tag(@block_ctxt cx,
14481447
i += 1;
14491448
}
14501449

1451-
auto tup_ty = ty.plain_tup_ty(true_arg_tys);
1450+
auto tup_ty = ty.mk_imm_tup(true_arg_tys);
14521451

14531452
// Cast the blob pointer to the appropriate type, if we need to (i.e. if
14541453
// the blob pointer isn't dynamically sized).
@@ -1488,8 +1487,8 @@ fn trans_raw_malloc(@block_ctxt cx, TypeRef llptr_ty, ValueRef llsize)
14881487
fn trans_malloc_boxed(@block_ctxt cx, @ty.t t) -> result {
14891488
// Synthesize a fake box type structurally so we have something
14901489
// to measure the size of.
1491-
auto boxed_body = ty.plain_tup_ty(vec(plain_ty(ty.ty_int), t));
1492-
auto box_ptr = ty.plain_box_ty(t, ast.imm);
1490+
auto boxed_body = ty.mk_imm_tup(vec(ty.mk_int(), t));
1491+
auto box_ptr = ty.mk_imm_box(t);
14931492
auto sz = size_of(cx, boxed_body);
14941493
auto llty = type_of(cx.fcx.lcx.ccx, box_ptr);
14951494
ret trans_raw_malloc(sz.bcx, llty, sz.val);
@@ -2294,13 +2293,6 @@ fn tag_variant_with_id(@crate_ctxt cx,
22942293
fail;
22952294
}
22962295

2297-
// Returns a new plain tag type of the given ID with no type parameters. Don't
2298-
// use this function in new code; it's a hack to keep things working for now.
2299-
fn mk_plain_tag(ast.def_id tid) -> @ty.t {
2300-
let vec[@ty.t] tps = vec();
2301-
ret ty.plain_ty(ty.ty_tag(tid, tps));
2302-
}
2303-
23042296

23052297
type val_pair_fn = fn(@block_ctxt cx, ValueRef dst, ValueRef src) -> result;
23062298

@@ -2341,8 +2333,8 @@ fn iter_structural_ty_full(@block_ctxt cx,
23412333
val_pair_and_ty_fn f) -> result {
23422334
auto box_a_ptr = cx.build.Load(box_a_cell);
23432335
auto box_b_ptr = cx.build.Load(box_b_cell);
2344-
auto tnil = plain_ty(ty.ty_nil);
2345-
auto tbox = ty.plain_box_ty(tnil, ast.imm);
2336+
auto tnil = ty.mk_nil();
2337+
auto tbox = ty.mk_imm_box(tnil);
23462338

23472339
auto inner_cx = new_sub_block_ctxt(cx, "iter box");
23482340
auto next_cx = new_sub_block_ctxt(cx, "next");
@@ -2407,8 +2399,7 @@ fn iter_structural_ty_full(@block_ctxt cx,
24072399
// NB: we must hit the discriminant first so that structural
24082400
// comparison know not to proceed when the discriminants differ.
24092401
auto bcx = cx;
2410-
bcx = f(bcx, lldiscrim_a, lldiscrim_b,
2411-
plain_ty(ty.ty_int)).bcx;
2402+
bcx = f(bcx, lldiscrim_a, lldiscrim_b, ty.mk_int()).bcx;
24122403

24132404
auto unr_cx = new_sub_block_ctxt(bcx, "tag-iter-unr");
24142405
unr_cx.build.Unreachable();
@@ -2628,7 +2619,7 @@ fn iter_sequence(@block_ctxt cx,
26282619
ret iter_sequence_body(cx, v, elt.ty, f, false);
26292620
}
26302621
case (ty.ty_str) {
2631-
auto et = plain_ty(ty.ty_machine(common.ty_u8));
2622+
auto et = ty.mk_mach(common.ty_u8);
26322623
ret iter_sequence_body(cx, v, et, f, true);
26332624
}
26342625
case (_) { fail; }
@@ -3449,7 +3440,7 @@ fn trans_for_each(@block_ctxt cx,
34493440

34503441
auto lcx = cx.fcx.lcx;
34513442
// FIXME: possibly support alias-mode here?
3452-
auto decl_ty = plain_ty(ty.ty_nil);
3443+
auto decl_ty = ty.mk_nil();
34533444
auto decl_id;
34543445
alt (decl.node) {
34553446
case (ast.decl_local(?local)) {
@@ -3536,7 +3527,7 @@ fn trans_for_each(@block_ctxt cx,
35363527
auto iter_body_llty = type_of_fn_full(lcx.ccx, ast.proto_fn,
35373528
none[TypeRef],
35383529
vec(rec(mode=ast.val, ty=decl_ty)),
3539-
plain_ty(ty.ty_nil), 0u);
3530+
ty.mk_nil(), 0u);
35403531

35413532
let ValueRef lliterbody = decl_internal_fastcall_fn(lcx.ccx.llmod,
35423533
s, iter_body_llty);
@@ -4235,8 +4226,7 @@ fn trans_bind_thunk(@local_ctxt cx,
42354226
auto bcx = new_top_block_ctxt(fcx);
42364227
auto lltop = bcx.llbb;
42374228

4238-
auto llclosure_ptr_ty = type_of(cx.ccx, ty.plain_box_ty(closure_ty,
4239-
ast.imm));
4229+
auto llclosure_ptr_ty = type_of(cx.ccx, ty.mk_imm_box(closure_ty));
42404230
auto llclosure = bcx.build.PointerCast(fcx.llenv, llclosure_ptr_ty);
42414231

42424232
auto lltarget = GEP_tup_like(bcx, closure_ty, llclosure,
@@ -4411,12 +4401,12 @@ fn trans_bind(@block_ctxt cx, @ast.expr f,
44114401
}
44124402

44134403
// Synthesize a closure type.
4414-
let @ty.t bindings_ty = ty.plain_tup_ty(bound_tys);
4404+
let @ty.t bindings_ty = ty.mk_imm_tup(bound_tys);
44154405

44164406
// NB: keep this in sync with T_closure_ptr; we're making
44174407
// a ty.t structure that has the same "shape" as the LLVM type
44184408
// it constructs.
4419-
let @ty.t tydesc_ty = plain_ty(ty.ty_type);
4409+
let @ty.t tydesc_ty = ty.mk_type();
44204410

44214411
let vec[@ty.t] captured_tys =
44224412
_vec.init_elt[@ty.t](tydesc_ty, ty_param_count);
@@ -4425,9 +4415,9 @@ fn trans_bind(@block_ctxt cx, @ast.expr f,
44254415
vec(tydesc_ty,
44264416
outgoing_fty,
44274417
bindings_ty,
4428-
ty.plain_tup_ty(captured_tys));
4418+
ty.mk_imm_tup(captured_tys));
44294419

4430-
let @ty.t closure_ty = ty.plain_tup_ty(closure_tys);
4420+
let @ty.t closure_ty = ty.mk_imm_tup(closure_tys);
44314421

44324422
auto r = trans_malloc_boxed(bcx, closure_ty);
44334423
auto box = r.val;
@@ -4829,8 +4819,8 @@ fn trans_vec(@block_ctxt cx, vec[@ast.expr] args,
48294819
C_int(abi.vec_elt_data)));
48304820

48314821
auto pseudo_tup_ty =
4832-
ty.plain_tup_ty(_vec.init_elt[@ty.t](unit_ty,
4833-
_vec.len[@ast.expr](args)));
4822+
ty.mk_imm_tup(_vec.init_elt[@ty.t](unit_ty,
4823+
_vec.len[@ast.expr](args)));
48344824
let int i = 0;
48354825

48364826
for (@ast.expr e in args) {
@@ -5927,7 +5917,7 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) {
59275917

59285918
// Synthesize a tuple type for the fields so that GEP_tup_like() can work
59295919
// its magic.
5930-
auto fields_tup_ty = ty.plain_tup_ty(field_tys);
5920+
auto fields_tup_ty = ty.mk_imm_tup(field_tys);
59315921

59325922
auto n_typarams = _vec.len[ast.ty_param](bcx.fcx.lcx.obj_typarams);
59335923
let TypeRef llobj_box_ty = T_obj_ptr(bcx.fcx.lcx.ccx.tn, n_typarams);
@@ -6152,18 +6142,18 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
61526142
}
61536143

61546144
// Synthesize an obj body type.
6155-
auto tydesc_ty = plain_ty(ty.ty_type);
6145+
auto tydesc_ty = ty.mk_type();
61566146
let vec[@ty.t] tps = vec();
61576147
for (ast.ty_param tp in ty_params) {
61586148
_vec.push[@ty.t](tps, tydesc_ty);
61596149
}
61606150

6161-
let @ty.t typarams_ty = ty.plain_tup_ty(tps);
6162-
let @ty.t fields_ty = ty.plain_tup_ty(obj_fields);
6163-
let @ty.t body_ty = ty.plain_tup_ty(vec(tydesc_ty,
6164-
typarams_ty,
6165-
fields_ty));
6166-
let @ty.t boxed_body_ty = ty.plain_box_ty(body_ty, ast.imm);
6151+
let @ty.t typarams_ty = ty.mk_imm_tup(tps);
6152+
let @ty.t fields_ty = ty.mk_imm_tup(obj_fields);
6153+
let @ty.t body_ty = ty.mk_imm_tup(vec(tydesc_ty,
6154+
typarams_ty,
6155+
fields_ty));
6156+
let @ty.t boxed_body_ty = ty.mk_imm_box(body_ty);
61676157

61686158
// Malloc a box for the body.
61696159
auto box = trans_malloc_boxed(bcx, body_ty);
@@ -6265,7 +6255,7 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
62656255
let vec[@ty.t] ty_param_substs = vec();
62666256
i = 0u;
62676257
for (ast.ty_param tp in ty_params) {
6268-
ty_param_substs += vec(plain_ty(ty.ty_param(i)));
6258+
ty_param_substs += vec(ty.mk_param(i));
62696259
i += 1u;
62706260
}
62716261

0 commit comments

Comments
 (0)