Skip to content

Commit ab69c4a

Browse files
committed
Removing dead code and redundant fails; changing fails to sess.bug
calls (issue #444).
1 parent b1d6f12 commit ab69c4a

File tree

5 files changed

+93
-158
lines changed

5 files changed

+93
-158
lines changed

src/comp/middle/trans.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3687,13 +3687,11 @@ fn autoderef(&@block_ctxt cx, ValueRef v, &ty::t t) -> result {
36873687

36883688
v1 = load_if_immediate(cx, v1, t1);
36893689
}
3690-
case (_) {
3691-
ret res(cx, v1);
3692-
}
3690+
case (_) { break; }
36933691
}
36943692
}
36953693

3696-
fail; // fools the return-checker
3694+
ret res(cx, v1);
36973695
}
36983696

36993697
fn autoderefed_ty(&@crate_ctxt ccx, &ty::t t) -> ty::t {
@@ -3704,13 +3702,11 @@ fn autoderefed_ty(&@crate_ctxt ccx, &ty::t t) -> ty::t {
37043702
case (ty::ty_box(?mt)) {
37053703
t1 = mt.ty;
37063704
}
3707-
case (_) {
3708-
ret t1;
3709-
}
3705+
case (_) { break; }
37103706
}
37113707
}
37123708

3713-
fail; // fools the return-checker
3709+
ret t1;
37143710
}
37153711

37163712
fn trans_binary(&@block_ctxt cx, ast::binop op,
@@ -3876,7 +3872,7 @@ fn trans_if(&@block_ctxt cx, &@ast::expr cond,
38763872
}
38773873

38783874
// FIXME: This isn't quite right, particularly re: dynamic types
3879-
auto expr_ty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx.node_types,
3875+
auto expr_ty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx,
38803876
ann);
38813877
if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
38823878
expr_llty = T_typaram_ptr(cx.fcx.lcx.ccx.tn);
@@ -4260,7 +4256,7 @@ fn trans_pat_match(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
42604256

42614257
case (ast::pat_lit(?lt, ?ann)) {
42624258
auto lllit = trans_lit(cx.fcx.lcx.ccx, *lt, ann);
4263-
auto lltype = ty::ann_to_type(cx.fcx.lcx.ccx.tcx.node_types, ann);
4259+
auto lltype = ty::ann_to_type(cx.fcx.lcx.ccx.tcx, ann);
42644260
auto lleq = trans_compare(cx, ast::eq, lltype, llval, lllit);
42654261

42664262
auto matched_cx = new_sub_block_ctxt(lleq.bcx, "matched_cx");
@@ -4298,7 +4294,7 @@ fn trans_pat_match(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
42984294
cx.build.CondBr(lleq, matched_cx.llbb, next_cx.llbb);
42994295

43004296
auto ty_params =
4301-
ty::ann_to_type_params(cx.fcx.lcx.ccx.tcx.node_types, ann);
4297+
ty::ann_to_type_params(cx.fcx.lcx.ccx.tcx, ann);
43024298

43034299
if (vec::len[@ast::pat](subpats) > 0u) {
43044300
auto llblobptr = matched_cx.build.GEP(lltagptr,
@@ -4359,7 +4355,7 @@ fn trans_pat_binding(&@block_ctxt cx, &@ast::pat pat,
43594355
auto llblobptr = cx.build.GEP(lltagptr, [C_int(0), C_int(1)]);
43604356

43614357
auto ty_param_substs =
4362-
ty::ann_to_type_params(cx.fcx.lcx.ccx.tcx.node_types, ann);
4358+
ty::ann_to_type_params(cx.fcx.lcx.ccx.tcx, ann);
43634359

43644360
auto this_cx = cx;
43654361
auto i = 0;
@@ -4408,7 +4404,7 @@ fn trans_alt(&@block_ctxt cx, &@ast::expr expr,
44084404
"non-exhaustive match failure");
44094405

44104406
// FIXME: This isn't quite right, particularly re: dynamic types
4411-
auto expr_ty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx.node_types, ann);
4407+
auto expr_ty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx, ann);
44124408
auto expr_llty;
44134409
if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
44144410
expr_llty = T_typaram_ptr(cx.fcx.lcx.ccx.tn);
@@ -4473,8 +4469,8 @@ fn lval_generic_fn(&@block_ctxt cx,
44734469
lv = trans_external_path(cx, fn_id, tpt);
44744470
}
44754471

4476-
auto tys = ty::ann_to_type_params(cx.fcx.lcx.ccx.tcx.node_types, ann);
4477-
auto monoty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx.node_types, ann);
4472+
auto tys = ty::ann_to_type_params(cx.fcx.lcx.ccx.tcx, ann);
4473+
auto monoty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx, ann);
44784474

44794475
if (vec::len[ty::t](tys) != 0u) {
44804476
auto bcx = lv.res.bcx;
@@ -5361,7 +5357,7 @@ fn trans_call(&@block_ctxt cx, &@ast::expr f,
53615357

53625358
}
53635359

5364-
auto ret_ty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx.node_types, ann);
5360+
auto ret_ty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx, ann);
53655361
auto args_res = trans_args(f_res.res.bcx,
53665362
llenv, f_res.llobj,
53675363
f_res.generic,
@@ -6910,7 +6906,7 @@ fn is_terminated(&@block_ctxt cx) -> bool {
69106906
}
69116907

69126908
fn arg_tys_of_fn(&@crate_ctxt ccx, ast::ann ann) -> vec[ty::arg] {
6913-
alt (ty::struct(ccx.tcx, ty::ann_to_type(ccx.tcx.node_types, ann))) {
6909+
alt (ty::struct(ccx.tcx, ty::ann_to_type(ccx.tcx, ann))) {
69146910
case (ty::ty_fn(_, ?arg_tys, _, _)) {
69156911
ret arg_tys;
69166912
}
@@ -6927,7 +6923,7 @@ fn ret_ty_of_fn_ty(&@crate_ctxt ccx, ty::t t) -> ty::t {
69276923

69286924

69296925
fn ret_ty_of_fn(&@crate_ctxt ccx, ast::ann ann) -> ty::t {
6930-
ret ret_ty_of_fn_ty(ccx, ty::ann_to_type(ccx.tcx.node_types, ann));
6926+
ret ret_ty_of_fn_ty(ccx, ty::ann_to_type(ccx.tcx, ann));
69316927
}
69326928

69336929
fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, val_self_pair llself) {

src/comp/middle/tstate/auxiliary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ fn controlflow_def_id(&crate_ctxt ccx, &def_id d) -> controlflow {
482482
If it has a function type with a ! annotation,
483483
the answer is noreturn. */
484484
fn controlflow_expr(&crate_ctxt ccx, @expr e) -> controlflow {
485-
alt (ty::struct(ccx.tcx, ty::ann_to_type(ccx.tcx.node_types,
485+
alt (ty::struct(ccx.tcx, ty::ann_to_type(ccx.tcx,
486486
expr_ann(e)))) {
487487
case (ty::ty_fn(_,_,_,?cf)) {
488488
ret cf;

0 commit comments

Comments
 (0)