Skip to content

Commit 4303785

Browse files
committed
---
yaml --- r: 14398 b: refs/heads/try c: 5458da0 h: refs/heads/master v: v3
1 parent a119c09 commit 4303785

File tree

10 files changed

+38
-121
lines changed

10 files changed

+38
-121
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 789a1ae356f75ed7db75afd485e009ce32b2bd74
5+
refs/heads/try: 5458da0fd924c18791c80b31659469f636dcbb9a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/comp/middle/trans/alt.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ fn trans_opt(bcx: block, o: opt) -> opt_result {
6363
}
6464
}
6565

66-
// FIXME: invariant -- pat_id is bound in the def_map?
6766
fn variant_opt(ccx: @crate_ctxt, pat_id: ast::node_id) -> opt {
6867
let vdef = ast_util::variant_def_ids(ccx.tcx.def_map.get(pat_id));
6968
let variants = ty::enum_variants(ccx.tcx, vdef.enm);
@@ -499,20 +498,13 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef], f: mk_fail,
499498
_ { }
500499
}
501500
}
502-
let else_cx =
503-
alt kind {
504-
no_branch | single { bcx }
505-
_ { sub_block(bcx, "match_else") }
506-
};
507-
let sw;
508-
if kind == switch {
509-
sw = Switch(bcx, test_val, else_cx.llbb, opts.len());
510-
// FIXME This statement is purely here as a work-around for a bug that
511-
// I expect to be the same as issue #951. If I remove it, sw ends up
512-
// holding a corrupted value (when the compiler is optimized).
513-
// This can be removed after our next LLVM upgrade.
514-
val_ty(sw);
515-
} else { sw = C_int(ccx, 0); } // Placeholder for when not using a switch
501+
let else_cx = alt kind {
502+
no_branch | single { bcx }
503+
_ { sub_block(bcx, "match_else") }
504+
};
505+
let sw = if kind == switch {
506+
Switch(bcx, test_val, else_cx.llbb, opts.len())
507+
} else { C_int(ccx, 0) }; // Placeholder for when not using a switch
516508

517509
// Compile subtrees for each option
518510
for opt: opt in opts {
@@ -694,9 +686,6 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
694686
ast::pat_ident(_,inner) {
695687
if make_copy || ccx.copy_map.contains_key(pat.id) {
696688
let ty = node_id_type(bcx, pat.id);
697-
// FIXME: Could constrain pat_bind to make this
698-
// check unnecessary.
699-
check (type_has_static_size(ccx, ty));
700689
let llty = type_of(ccx, ty);
701690
let alloc = alloca(bcx, llty);
702691
bcx = copy_val(bcx, INIT, alloc,

branches/try/src/comp/middle/trans/base.rs

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,6 @@ fn type_of_ty_param_bounds_and_ty
186186
// fall through
187187
}
188188
}
189-
// FIXME: could have a precondition on tpt, but that
190-
// doesn't work right now because one predicate can't imply
191-
// another
192-
check type_has_static_size(ccx, t);
193189
type_of(ccx, t)
194190
}
195191

@@ -523,7 +519,6 @@ fn trans_malloc_boxed_raw(bcx: block, t: ty::t,
523519
// Grab the TypeRef type of box_ptr, because that's what trans_raw_malloc
524520
// wants.
525521
let box_ptr = ty::mk_imm_box(bcx.tcx(), t);
526-
check (type_has_static_size(ccx, box_ptr));
527522
let llty = type_of(ccx, box_ptr);
528523

529524
// Get the tydesc for the body:
@@ -792,7 +787,6 @@ fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef,
792787
ret llfn;
793788
}
794789

795-
// FIXME: was this causing the leak?
796790
fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t,
797791
llfn: ValueRef, helper: glue_helper,
798792
ty_params: [uint]) -> ValueRef {
@@ -1218,7 +1212,6 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
12181212
j += 1u;
12191213
}
12201214
}
1221-
// Precondition?
12221215
_ { cx.tcx().sess.bug("iter_variant: not a function type"); }
12231216
}
12241217
ret cx;
@@ -1460,7 +1453,6 @@ fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block {
14601453
ty::ty_box(_) | ty::ty_opaque_box {
14611454
decr_refcnt_maybe_free(bcx, v, t)
14621455
}
1463-
// Precondition?
14641456
_ { bcx.tcx().sess.bug("drop_ty_immediate: non-box ty"); }
14651457
}
14661458
}
@@ -1608,9 +1600,8 @@ fn move_val(cx: block, action: copy_action, dst: ValueRef,
16081600
revoke_clean(cx, src_val);
16091601
ret cx;
16101602
}
1611-
/* FIXME: suggests a type constraint */
16121603
cx.sess().bug("unexpected type in trans::move_val: " +
1613-
ty_to_str(tcx, t));
1604+
ty_to_str(tcx, t));
16141605
}
16151606

16161607
fn store_temp_expr(cx: block, action: copy_action, dst: ValueRef,
@@ -1718,9 +1709,7 @@ fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef,
17181709
ast::eq | ast::ne { llop = C_u8(abi::cmp_glue_op_eq); }
17191710
ast::lt | ast::ge { llop = C_u8(abi::cmp_glue_op_lt); }
17201711
ast::le | ast::gt { llop = C_u8(abi::cmp_glue_op_le); }
1721-
// Precondition?
1722-
_ { cx.tcx().sess.bug("trans_compare got\
1723-
non-comparison-op"); }
1712+
_ { cx.tcx().sess.bug("trans_compare got non-comparison-op"); }
17241713
}
17251714

17261715
let rs = call_cmp_glue(cx, lhs, rhs, rhs_t, llop);
@@ -2000,7 +1989,6 @@ fn store_in_dest(bcx: block, val: ValueRef, dest: dest) -> block {
20001989
fn get_dest_addr(dest: dest) -> ValueRef {
20011990
alt dest {
20021991
save_in(a) { a }
2003-
// Precondition?
20041992
_ { fail "get_dest_addr: not a save_in"; }
20051993
}
20061994
}
@@ -2079,7 +2067,7 @@ fn trans_while(cx: block, cond: @ast::expr, body: ast::blk)
20792067
-> block {
20802068
let next_cx = sub_block(cx, "while next");
20812069
let cond_cx = loop_scope_block(cx, cont_self, next_cx,
2082-
"while cond", body.span);
2070+
"while cond", body.span);
20832071
let body_cx = scope_block(cond_cx, "while loop body");
20842072
Br(cx, cond_cx.llbb);
20852073
let cond_res = trans_temp_expr(cond_cx, cond);
@@ -2483,9 +2471,9 @@ fn trans_callee(bcx: block, e: @ast::expr) -> lval_maybe_callee {
24832471
some(origin) { // An impl method
24842472
ret impl::trans_method_callee(bcx, e.id, base, origin);
24852473
}
2486-
// Precondition?
2487-
_ { bcx.tcx().sess.span_bug(e.span, "trans_callee: weird\
2488-
expr"); }
2474+
_ {
2475+
bcx.ccx().sess.span_bug(e.span, "trans_callee: weird expr");
2476+
}
24892477
}
24902478
}
24912479
}
@@ -2515,7 +2503,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result {
25152503
let ccx = cx.ccx();
25162504
let sub = trans_temp_expr(cx, base);
25172505
let t = expr_ty(cx, base);
2518-
let val = alt ty::get(t).struct {
2506+
let val = alt check ty::get(t).struct {
25192507
ty::ty_box(_) {
25202508
GEPi(sub.bcx, sub.val, [0, abi::box_field_body])
25212509
}
@@ -2524,18 +2512,12 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result {
25242512
}
25252513
ty::ty_enum(_, _) {
25262514
let ety = expr_ty(cx, e);
2527-
let ellty =
2528-
if check type_has_static_size(ccx, ety) {
2515+
let ellty = if check type_has_static_size(ccx, ety) {
25292516
T_ptr(type_of(ccx, ety))
25302517
} else { T_typaram_ptr(ccx.tn) };
25312518
PointerCast(sub.bcx, sub.val, ellty)
25322519
}
25332520
ty::ty_ptr(_) | ty::ty_uniq(_) { sub.val }
2534-
// Precondition?
2535-
_ {
2536-
cx.tcx().sess.span_bug(e.span, "trans_lval:\
2537-
Weird argument in deref");
2538-
}
25392521
};
25402522
ret lval_owned(sub.bcx, val);
25412523
}
@@ -2602,9 +2584,6 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id,
26022584
let e_res = trans_temp_expr(cx, e);
26032585
let ll_t_in = val_ty(e_res.val);
26042586
let t_in = expr_ty(cx, e);
2605-
// Check should be avoidable because it's a cast.
2606-
// FIXME: Constrain types so as to avoid this check.
2607-
check (type_has_static_size(ccx, t_out));
26082587
let ll_t_out = type_of(ccx, t_out);
26092588

26102589
enum kind { pointer, integral, float, enum_, other, }
@@ -3210,11 +3189,6 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
32103189
ret trans_ret(bcx, ex);
32113190
}
32123191
ast::expr_be(ex) {
3213-
// Ideally, the expr_be enum would have a precondition
3214-
// that is_call_expr(ex) -- but we don't support that
3215-
// yet
3216-
// FIXME
3217-
check (ast_util::is_call_expr(ex));
32183192
ret trans_be(bcx, ex);
32193193
}
32203194
ast::expr_fail(expr) {
@@ -3526,9 +3500,7 @@ fn trans_ret(bcx: block, e: option<@ast::expr>) -> block {
35263500

35273501
fn build_return(bcx: block) { Br(bcx, bcx.fcx.llreturn); }
35283502

3529-
// fn trans_be(cx: &block, e: &@ast::expr) -> result {
3530-
fn trans_be(cx: block, e: @ast::expr) : ast_util::is_call_expr(e) ->
3531-
block {
3503+
fn trans_be(cx: block, e: @ast::expr) -> block {
35323504
// FIXME: Turn this into a real tail call once
35333505
// calling convention issues are settled
35343506
ret trans_ret(cx, some(e));
@@ -4399,13 +4371,11 @@ fn trans_mod(ccx: @crate_ctxt, m: ast::_mod) {
43994371

44004372
fn get_pair_fn_ty(llpairty: TypeRef) -> TypeRef {
44014373
// Bit of a kludge: pick the fn typeref out of the pair.
4402-
44034374
ret struct_elt(llpairty, 0u);
44044375
}
44054376

44064377
fn register_fn(ccx: @crate_ctxt, sp: span, path: path, flav: str,
44074378
ty_params: [ast::ty_param], node_id: ast::node_id) {
4408-
// FIXME: pull this out
44094379
let t = ty::node_id_to_type(ccx.tcx, node_id);
44104380
register_fn_full(ccx, sp, path, flav, ty_params, node_id, t);
44114381
}
@@ -4461,7 +4431,6 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
44614431
let vecarg_ty: ty::arg =
44624432
{mode: ast::expl(ast::by_val),
44634433
ty: ty::mk_vec(ccx.tcx, {ty: unit_ty, mutbl: ast::m_imm})};
4464-
// FIXME: mk_nil should have a postcondition
44654434
let nt = ty::mk_nil(ccx.tcx);
44664435
let llfty = type_of_fn(ccx, [vecarg_ty], nt, []);
44674436
let llfdecl = decl_fn(ccx.llmod, "_rust_main",
@@ -4600,10 +4569,7 @@ fn collect_item(ccx: @crate_ctxt, abi: @mutable option<ast::native_abi>,
46004569
ast::item_const(_, _) {
46014570
let typ = ty::node_id_to_type(ccx.tcx, i.id);
46024571
let s = mangle_exported_name(ccx, my_path, typ);
4603-
// FIXME: Could follow from a constraint on types of const
4604-
// items
46054572
let g = str::as_buf(s, {|buf|
4606-
check (type_has_static_size(ccx, typ));
46074573
llvm::LLVMAddGlobal(ccx.llmod, type_of(ccx, typ), buf)
46084574
});
46094575
ccx.item_symbols.insert(i.id, s);
@@ -4639,7 +4605,6 @@ fn collect_item(ccx: @crate_ctxt, abi: @mutable option<ast::native_abi>,
46394605
// ty_res, which would have to carry around two def_ids otherwise
46404606
// -- one to identify the type, and one to find the dtor symbol.
46414607
let t = ty::node_id_to_type(ccx.tcx, dtor_id);
4642-
// FIXME: how to get rid of this check?
46434608
register_fn_full(ccx, i.span, my_path + [path_name("dtor")],
46444609
"res_dtor", tps, i.id, t);
46454610
}

branches/try/src/comp/middle/trans/closure.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -718,17 +718,7 @@ fn trans_bind_thunk(ccx: @crate_ctxt,
718718
param_bounds: [ty::param_bounds],
719719
target_info: target_info)
720720
-> {val: ValueRef, ty: TypeRef} {
721-
722-
// If we supported constraints on record fields, we could make the
723-
// constraints for this function:
724-
/*
725-
: returns_non_ty_var(outgoing_fty),
726-
type_has_static_size(ccx, incoming_fty) ->
727-
*/
728-
// but since we don't, we have to do the checks at the beginning.
729721
let tcx = ccx.tcx;
730-
check type_has_static_size(ccx, incoming_fty);
731-
732722
#debug["trans_bind_thunk[incoming_fty=%s,outgoing_fty=%s,\
733723
cdata_ty=%s,param_bounds=%?]",
734724
ty_to_str(tcx, incoming_fty),

branches/try/src/comp/middle/trans/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ fn get_res_dtor(ccx: @crate_ctxt, did: ast::def_id, inner_t: ty::t)
294294
if did.crate == ast::local_crate {
295295
alt ccx.item_ids.find(did.node) {
296296
some(x) { ret x; }
297-
_ { ccx.tcx.sess.bug("get_res_dtor: can't find resource dtor!"); }
297+
_ { ccx.sess.bug("get_res_dtor: can't find resource dtor!"); }
298298
}
299299
}
300300

@@ -364,8 +364,8 @@ type block = @{
364364
// First two args are retptr, env
365365
const first_tp_arg: uint = 2u;
366366

367-
// FIXME: we should be able to use option<@block_parent> here but
368-
// the infinite-enum check in rustboot gets upset.
367+
// FIXME move blocks to a class once those are finished, and simply use
368+
// option<block> for this.
369369
enum block_parent { parent_none, parent_some(block), }
370370

371371
type result = {bcx: block, val: ValueRef};

branches/try/src/comp/middle/trans/debuginfo.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
601601
ty::ty_vec(mt) { ast::ty_vec({ty: t_to_ty(cx, mt.ty, span),
602602
mutbl: mt.mutbl}) }
603603
_ {
604-
cx.tcx.sess.span_bug(span, "t_to_ty: Can't handle this type");
604+
cx.sess.span_bug(span, "t_to_ty: Can't handle this type");
605605
}
606606
};
607607
ret @{node: ty, span: span};
@@ -611,7 +611,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
611611
ast::ty_box(mt) {
612612
let inner_t = alt ty::get(t).struct {
613613
ty::ty_box(boxed) { boxed.ty }
614-
_ { cx.tcx.sess.span_bug(ty.span, "t_to_ty was incoherent"); }
614+
_ { cx.sess.span_bug(ty.span, "t_to_ty was incoherent"); }
615615
};
616616
let md = create_ty(cx, inner_t, mt.ty);
617617
let box = create_boxed_type(cx, t, inner_t, ty.span, md);
@@ -622,7 +622,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
622622
let inner_t = alt ty::get(t).struct {
623623
ty::ty_uniq(boxed) { boxed.ty }
624624
// Hoping we'll have a way to eliminate this check soon.
625-
_ { cx.tcx.sess.span_bug(ty.span, "t_to_ty was incoherent"); }
625+
_ { cx.sess.span_bug(ty.span, "t_to_ty was incoherent"); }
626626
};
627627
let md = create_ty(cx, inner_t, mt.ty);
628628
ret create_pointer_type(cx, t, ty.span, md);

branches/try/src/comp/middle/trans/impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident,
5353
tps + m.tps, none, m.id);
5454
}
5555
_ {
56-
ccx.tcx.sess.bug("Unbound id in trans_impl");
56+
ccx.sess.bug("Unbound id in trans_impl");
5757
}
5858
}
5959
}
@@ -337,7 +337,7 @@ fn trans_impl_vtable(ccx: @crate_ctxt, pt: path,
337337
target)
338338
}
339339
_ {
340-
ccx.tcx.sess.span_bug(it.span, "No matching method \
340+
ccx.sess.span_bug(it.span, "No matching method \
341341
in trans_impl_vtable");
342342
}
343343
}

branches/try/src/comp/middle/trans/native.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ fn c_arg_and_ret_lltys(ccx: @crate_ctxt,
3434
let llretty = type_of(ccx, ret_ty);
3535
(llargtys, llretty, ret_ty)
3636
}
37-
_ {
38-
// Precondition?
39-
ccx.tcx.sess.bug("c_arg_and_ret_lltys called on non-function type");
40-
}
37+
_ { ccx.sess.bug("c_arg_and_ret_lltys called on non-function type"); }
4138
}
4239
}
4340

0 commit comments

Comments
 (0)