Skip to content

Commit 5777582

Browse files
committed
---
yaml --- r: 8105 b: refs/heads/snap-stage3 c: 8673c4f h: refs/heads/master i: 8103: ac635a0 v: v3
1 parent 4767552 commit 5777582

27 files changed

+662
-970
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 6ed8d037841aab1b2855525bf141c5c1c4de4910
4+
refs/heads/snap-stage3: 8673c4f195be8377f8e0d83929f9a16bb99092a0
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/src/comp/metadata/decoder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn doc_type(doc: ebml::doc, tcx: ty::ctxt, cdata: cmd) -> ty::t {
113113
fn item_type(item: ebml::doc, tcx: ty::ctxt, cdata: cmd) -> ty::t {
114114
let t = doc_type(item, tcx, cdata);
115115
if family_names_type(item_family(item)) {
116-
ty::mk_named(tcx, t, @item_name(item))
116+
ty::mk_named(tcx, t, item_name(item))
117117
} else { t }
118118
}
119119

@@ -247,7 +247,7 @@ fn get_enum_variants(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
247247
let ctor_ty = item_type(item, tcx, cdata);
248248
let name = item_name(item);
249249
let arg_tys: [ty::t] = [];
250-
alt ty::struct(tcx, ctor_ty) {
250+
alt ty::get(ctor_ty).struct {
251251
ty::ty_fn(f) {
252252
for a: ty::arg in f.inputs { arg_tys += [a.ty]; }
253253
}
@@ -302,7 +302,7 @@ fn get_iface_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
302302
let bounds = item_ty_param_bounds(mth, tcx, cdata);
303303
let name = item_name(mth);
304304
let ty = doc_type(mth, tcx, cdata);
305-
let fty = alt ty::struct(tcx, ty) { ty::ty_fn(f) { f }
305+
let fty = alt ty::get(ty).struct { ty::ty_fn(f) { f }
306306
_ { tcx.sess.bug("get_iface_methods: id has non-function type");
307307
} };
308308
result += [{ident: name, tps: bounds, fty: fty}];

branches/snap-stage3/src/comp/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
353353
encode_def_id(ebml_w, local_def(ctor_id));
354354
encode_family(ebml_w, 'y' as u8);
355355
encode_type_param_bounds(ebml_w, ecx, tps);
356-
encode_type(ecx, ebml_w, ty::ty_fn_ret(tcx, fn_ty));
356+
encode_type(ecx, ebml_w, ty::ty_fn_ret(fn_ty));
357357
encode_name(ebml_w, item.ident);
358358
encode_symbol(ecx, ebml_w, item.id);
359359
ebml::end_tag(ebml_w);

branches/snap-stage3/src/comp/metadata/tydecode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
299299
while peek(st) as char != '"' { str::push_byte(name, next(st)); }
300300
st.pos = st.pos + 1u;
301301
let inner = parse_ty(st, conv);
302-
ty::mk_named(st.tcx, inner, @name)
302+
ty::mk_named(st.tcx, inner, name)
303303
}
304304
c { #error("unexpected char in type string: %c", c); fail;}
305305
}

branches/snap-stage3/src/comp/metadata/tyencode.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) {
4242
some(s) { *s }
4343
none {
4444
let buf = io::mk_mem_buffer();
45-
enc_sty(io::mem_buffer_writer(buf), cx,
46-
ty::struct_raw(cx.tcx, t));
45+
enc_sty(io::mem_buffer_writer(buf), cx, ty::get(t).struct);
4746
cx.tcx.short_names_cache.insert(t, @io::mem_buffer_str(buf));
4847
io::mem_buffer_str(buf)
4948
}
@@ -55,7 +54,15 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) {
5554
some(a) { w.write_str(*a.s); ret; }
5655
none {
5756
let pos = w.tell();
58-
enc_sty(w, cx, ty::struct_raw(cx.tcx, t));
57+
alt ty::type_name(t) {
58+
some(n) {
59+
w.write_char('"');
60+
w.write_str(n);
61+
w.write_char('"');
62+
}
63+
_ {}
64+
}
65+
enc_sty(w, cx, ty::get(t).struct);
5966
let end = w.tell();
6067
let len = end - pos;
6168
fn estimate_sz(u: uint) -> uint {
@@ -185,14 +192,6 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
185192
for tc: @ty::type_constr in cs { enc_ty_constr(w, cx, tc); }
186193
w.write_char(']');
187194
}
188-
ty::ty_named(t, name) {
189-
if cx.abbrevs != ac_no_abbrevs {
190-
w.write_char('"');
191-
w.write_str(*name);
192-
w.write_char('"');
193-
}
194-
enc_ty(w, cx, t);
195-
}
196195
}
197196
}
198197
fn enc_proto(w: io::writer, proto: proto) {

branches/snap-stage3/src/comp/middle/alias.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fn visit_fn(cx: @ctx, _fk: visit::fn_kind, decl: ast::fn_decl,
8080
id: ast::node_id, sc: scope, v: vt<scope>) {
8181
visit::visit_fn_decl(decl, sc, v);
8282
let fty = ty::node_id_to_type(cx.tcx, id);
83-
let args = ty::ty_fn_args(cx.tcx, fty);
83+
let args = ty::ty_fn_args(fty);
8484
for arg in args {
8585
alt ty::resolved_mode(cx.tcx, arg.mode) {
8686
ast::by_val if ty::type_has_dynamic_size(cx.tcx, arg.ty) {
@@ -92,7 +92,7 @@ fn visit_fn(cx: @ctx, _fk: visit::fn_kind, decl: ast::fn_decl,
9292

9393
// Blocks need to obey any restrictions from the enclosing scope, and may
9494
// be called multiple times.
95-
let proto = ty::ty_fn_proto(cx.tcx, fty);
95+
let proto = ty::ty_fn_proto(fty);
9696
alt proto {
9797
ast::proto_block | ast::proto_any {
9898
check_loop(*cx, sc) {|| v.visit_block(body, sc, v);}
@@ -221,7 +221,7 @@ fn cant_copy(cx: ctx, b: binding) -> bool {
221221
fn check_call(cx: ctx, sc: scope, f: @ast::expr, args: [@ast::expr])
222222
-> [binding] {
223223
let fty = ty::expr_ty(cx.tcx, f);
224-
let arg_ts = ty::ty_fn_args(cx.tcx, fty);
224+
let arg_ts = ty::ty_fn_args(fty);
225225
let mut_roots: [{arg: uint, node: node_id}] = [];
226226
let bindings = [];
227227
let i = 0u;
@@ -371,7 +371,7 @@ fn check_for(cx: ctx, local: @ast::local, seq: @ast::expr, blk: ast::blk,
371371
// If this is a mutable vector, don't allow it to be touched.
372372
let seq_t = ty::expr_ty(cx.tcx, seq);
373373
let cur_mut = root.mut;
374-
alt ty::struct(cx.tcx, seq_t) {
374+
alt ty::get(seq_t).struct {
375375
ty::ty_vec(mt) {
376376
if mt.mut != ast::imm {
377377
cur_mut = some(contains(seq_t));
@@ -510,7 +510,7 @@ fn ty_can_unsafely_include(cx: ctx, needle: unsafe_ty, haystack: ty::t,
510510
contains(ty) { ty == haystack }
511511
mut_contains(ty) { mut && ty == haystack }
512512
} { ret true; }
513-
alt ty::struct(tcx, haystack) {
513+
alt ty::get(haystack).struct {
514514
ty::ty_enum(_, ts) {
515515
for t: ty::t in ts {
516516
if helper(tcx, needle, t, mut) { ret true; }
@@ -565,7 +565,7 @@ fn local_id_of_node(cx: ctx, id: node_id) -> uint {
565565
// implicit copy.
566566
fn copy_is_expensive(tcx: ty::ctxt, ty: ty::t) -> bool {
567567
fn score_ty(tcx: ty::ctxt, ty: ty::t) -> uint {
568-
ret alt ty::struct(tcx, ty) {
568+
ret alt ty::get(ty).struct {
569569
ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_int(_) |
570570
ty::ty_uint(_) | ty::ty_float(_) | ty::ty_type |
571571
ty::ty_ptr(_) { 1u }
@@ -623,7 +623,7 @@ fn pattern_roots(tcx: ty::ctxt, mut: option<unsafe_ty>, pat: @ast::pat)
623623
}
624624
ast::pat_box(p) {
625625
let ty = ty::node_id_to_type(tcx, pat.id);
626-
let m = alt ty::struct(tcx, ty) {
626+
let m = alt ty::get(ty).struct {
627627
ty::ty_box(mt) { mt.mut != ast::imm }
628628
_ { tcx.sess.span_bug(pat.span, "box pat has non-box type"); }
629629
},
@@ -632,7 +632,7 @@ fn pattern_roots(tcx: ty::ctxt, mut: option<unsafe_ty>, pat: @ast::pat)
632632
}
633633
ast::pat_uniq(p) {
634634
let ty = ty::node_id_to_type(tcx, pat.id);
635-
let m = alt ty::struct(tcx, ty) {
635+
let m = alt ty::get(ty).struct {
636636
ty::ty_uniq(mt) { mt.mut != ast::imm }
637637
_ { tcx.sess.span_bug(pat.span, "uniq pat has non-uniq type"); }
638638
},

branches/snap-stage3/src/comp/middle/block_use.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) {
1313

1414
fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
1515
if !cx.allow_block {
16-
alt ty::struct(cx.tcx, ty::expr_ty(cx.tcx, ex)) {
16+
alt ty::get(ty::expr_ty(cx.tcx, ex)).struct {
1717
ty::ty_fn({proto: p, _}) if is_blockish(p) {
1818
cx.tcx.sess.span_err(ex.span, "expressions with block type \
1919
can only appear in callee or (by-ref) argument position");
@@ -27,7 +27,7 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
2727
cx.allow_block = true;
2828
v.visit_expr(f, cx, v);
2929
let i = 0u;
30-
for arg_t in ty::ty_fn_args(cx.tcx, ty::expr_ty(cx.tcx, f)) {
30+
for arg_t in ty::ty_fn_args(ty::expr_ty(cx.tcx, f)) {
3131
cx.allow_block = (ty::arg_mode(cx.tcx, arg_t) == by_ref);
3232
v.visit_expr(args[i], cx, v);
3333
i += 1u;

branches/snap-stage3/src/comp/middle/check_alt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn check_exhaustive(tcx: ty::ctxt, sp:span, scrut_ty:ty::t, pats:[@pat]) {
7373
/* Otherwise, get the list of variants and make sure each one is
7474
represented. Then recurse on the columns. */
7575

76-
let ty_def_id = alt ty::struct(tcx, scrut_ty) {
76+
let ty_def_id = alt ty::get(scrut_ty).struct {
7777
ty_enum(id, _) { id }
7878
_ { ret; } };
7979

branches/snap-stage3/src/comp/middle/debuginfo.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
280280
let cache = get_cache(cx);
281281
let tg = BasicTypeDescriptorTag;
282282
alt cached_metadata::<@metadata<tydesc_md>>(
283-
cache, tg, {|md| t == md.data.hash}) {
283+
cache, tg, {|md| ty::type_id(t) == md.data.hash}) {
284284
option::some(md) { ret md; }
285285
option::none {}
286286
}
@@ -325,7 +325,7 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
325325
lli32(0), //XXX flags?
326326
lli32(encoding)];
327327
let llnode = llmdnode(lldata);
328-
let mdval = @{node: llnode, data: {hash: t}};
328+
let mdval = @{node: llnode, data: {hash: ty::type_id(t)}};
329329
update_cache(cache, tg, tydesc_metadata(mdval));
330330
add_named_metadata(cx, "llvm.dbg.ty", llnode);
331331
ret mdval;
@@ -347,7 +347,7 @@ fn create_pointer_type(cx: @crate_ctxt, t: ty::t, span: span,
347347
//let cu_node = create_compile_unit(cx, fname);
348348
let llnode = create_derived_type(tg, file_node.node, "", 0, size * 8,
349349
align * 8, 0, pointee.node);
350-
let mdval = @{node: llnode, data: {hash: t}};
350+
let mdval = @{node: llnode, data: {hash: ty::type_id(t)}};
351351
//update_cache(cache, tg, tydesc_metadata(mdval));
352352
add_named_metadata(cx, "llvm.dbg.ty", llnode);
353353
ret mdval;
@@ -420,7 +420,7 @@ fn create_record(cx: @crate_ctxt, t: ty::t, fields: [ast::ty_field],
420420
line_from_span(cx.sess.codemap, field.span) as int,
421421
size as int, align as int, ty_md.node);
422422
}
423-
let mdval = @{node: finish_structure(scx), data:{hash: t}};
423+
let mdval = @{node: finish_structure(scx), data:{hash: ty::type_id(t)}};
424424
ret mdval;
425425
}
426426

@@ -448,7 +448,7 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t,
448448
8, //XXX just a guess
449449
boxed.node);
450450
let llnode = finish_structure(scx);
451-
let mdval = @{node: llnode, data: {hash: outer}};
451+
let mdval = @{node: llnode, data: {hash: ty::type_id(outer)}};
452452
//update_cache(cache, tg, tydesc_metadata(mdval));
453453
add_named_metadata(cx, "llvm.dbg.ty", llnode);
454454
ret mdval;
@@ -507,7 +507,7 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t,
507507
add_member(scx, "data", 0, 0, // clang says the size should be 0
508508
sys::align_of::<u8>() as int, data_ptr);
509509
let llnode = finish_structure(scx);
510-
ret @{node: llnode, data: {hash: vec_t}};
510+
ret @{node: llnode, data: {hash: ty::type_id(vec_t)}};
511511
}
512512

513513
fn member_size_and_align(ty: @ast::ty) -> (int, int) {
@@ -561,7 +561,7 @@ fn create_ty(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
561561
}*/
562562

563563
fn t_to_ty(cx: @crate_ctxt, t: ty::t, span: span) -> @ast::ty {
564-
let ty = alt ty::struct(ccx_tcx(cx), t) {
564+
let ty = alt ty::get(t).struct {
565565
ty::ty_nil { ast::ty_nil }
566566
ty::ty_bot { ast::ty_bot }
567567
ty::ty_bool { ast::ty_bool }
@@ -593,7 +593,7 @@ fn create_ty(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
593593

594594
alt ty.node {
595595
ast::ty_box(mt) {
596-
let inner_t = alt ty::struct(ccx_tcx(cx), t) {
596+
let inner_t = alt ty::get(t).struct {
597597
ty::ty_box(boxed) { boxed.ty }
598598
_ { cx.tcx.sess.span_bug(ty.span, "t_to_ty was incoherent"); }
599599
};
@@ -603,7 +603,7 @@ fn create_ty(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
603603
}
604604

605605
ast::ty_uniq(mt) {
606-
let inner_t = alt ty::struct(ccx_tcx(cx), t) {
606+
let inner_t = alt ty::get(t).struct {
607607
ty::ty_uniq(boxed) { boxed.ty }
608608
// Hoping we'll have a way to eliminate this check soon.
609609
_ { cx.tcx.sess.span_bug(ty.span, "t_to_ty was incoherent"); }

branches/snap-stage3/src/comp/middle/fn_usage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn fn_usage_expr(expr: @ast::expr,
3131
}
3232
if !ctx.generic_bare_fn_legal
3333
&& ty::expr_has_ty_params(ctx.tcx, expr) {
34-
alt ty::struct(ctx.tcx, ty::expr_ty(ctx.tcx, expr)) {
34+
alt ty::get(ty::expr_ty(ctx.tcx, expr)).struct {
3535
ty::ty_fn({proto: ast::proto_bare, _}) {
3636
ctx.tcx.sess.span_fatal(
3737
expr.span,

branches/snap-stage3/src/comp/middle/kind.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn check_crate(tcx: ty::ctxt, method_map: typeck::method_map,
6060
fn with_appropriate_checker(cx: ctx, id: node_id,
6161
b: fn(fn@(ctx, ty::t, sp: span))) {
6262
let fty = ty::node_id_to_type(cx.tcx, id);
63-
alt ty::ty_fn_proto(cx.tcx, fty) {
63+
alt ty::ty_fn_proto(fty) {
6464
proto_uniq { b(check_send); }
6565
proto_box { b(check_copy); }
6666
proto_bare { b(check_none); }
@@ -142,9 +142,10 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
142142
some(ex) {
143143
// All noncopyable fields must be overridden
144144
let t = ty::expr_ty(cx.tcx, ex);
145-
let ty_fields = alt ty::struct(cx.tcx, t) { ty::ty_rec(f) { f }
146-
_ { cx.tcx.sess.span_bug(ex.span,
147-
"Bad expr type in record"); } };
145+
let ty_fields = alt ty::get(t).struct {
146+
ty::ty_rec(f) { f }
147+
_ { cx.tcx.sess.span_bug(ex.span, "Bad expr type in record"); }
148+
};
148149
for tf in ty_fields {
149150
if !vec::any(fields, {|f| f.node.ident == tf.ident}) &&
150151
!ty::kind_can_be_copied(ty::type_kind(cx.tcx, tf.mt.ty)) {
@@ -164,7 +165,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
164165
}
165166
expr_call(f, args, _) {
166167
let i = 0u;
167-
for arg_t in ty::ty_fn_args(cx.tcx, ty::expr_ty(cx.tcx, f)) {
168+
for arg_t in ty::ty_fn_args(ty::expr_ty(cx.tcx, f)) {
168169
alt ty::arg_mode(cx.tcx, arg_t) {
169170
by_copy { maybe_copy(cx, args[i]); }
170171
by_ref | by_val | by_mut_ref | by_move { }
@@ -242,7 +243,7 @@ fn check_copy_ex(cx: ctx, ex: @expr, _warn: bool) {
242243
check_copy(cx, ty, ex.span);
243244
// FIXME turn this on again once vector types are no longer unique.
244245
// Right now, it is too annoying to be useful.
245-
/* if warn && ty::type_is_unique(cx.tcx, ty) {
246+
/* if warn && ty::type_is_unique(ty) {
246247
cx.tcx.sess.span_warn(ex.span, "copying a unique value");
247248
}*/
248249
}

branches/snap-stage3/src/comp/middle/last_use.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn find_last_uses(c: @crate, def_map: resolve::def_map,
6565
}
6666

6767
fn ex_is_blockish(cx: ctx, id: node_id) -> bool {
68-
alt ty::struct(cx.tcx, ty::node_id_to_type(cx.tcx, id)) {
68+
alt ty::get(ty::node_id_to_type(cx.tcx, id)).struct {
6969
ty::ty_fn({proto: p, _}) if is_blockish(p) { true }
7070
_ { false }
7171
}
@@ -147,7 +147,7 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
147147
expr_call(f, args, _) {
148148
v.visit_expr(f, cx, v);
149149
let i = 0u, fns = [];
150-
let arg_ts = ty::ty_fn_args(cx.tcx, ty::expr_ty(cx.tcx, f));
150+
let arg_ts = ty::ty_fn_args(ty::expr_ty(cx.tcx, f));
151151
for arg in args {
152152
alt arg.node {
153153
expr_fn(p, _, _, _) if is_blockish(p) {
@@ -175,7 +175,7 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
175175
sp: span, id: node_id,
176176
cx: ctx, v: visit::vt<ctx>) {
177177
let fty = ty::node_id_to_type(cx.tcx, id);
178-
let proto = ty::ty_fn_proto(cx.tcx, fty);
178+
let proto = ty::ty_fn_proto(fty);
179179
alt proto {
180180
proto_any | proto_block {
181181
visit_block(func, cx, {||

0 commit comments

Comments
 (0)