Remove redundant 'fail' exprs and dead code; use sess.bug or
sess.span_err instead of 'fail'. (issue #444)
This commit is contained in:
parent
53ea2a4751
commit
5f95766a40
@ -308,7 +308,6 @@ fn resolve_names(&@env e, &ast::crate c) {
|
||||
case (_) {
|
||||
e.sess.span_err(p.span, "not a tag variant: " +
|
||||
str::connect(p.node.idents, "::"));
|
||||
fail;
|
||||
}
|
||||
}
|
||||
for (@ast::pat child in children) {
|
||||
@ -412,7 +411,6 @@ fn follow_import(&env e, &list[scope] sc, vec[ident] path, &span sp)
|
||||
case (_) {
|
||||
e.sess.span_err(sp, str::connect(path, "::")
|
||||
+ " does not name a module.");
|
||||
fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -508,12 +506,13 @@ fn lookup_in_scope_strict(&env e, list[scope] sc, &span sp, &ident id,
|
||||
alt (lookup_in_scope(e, sc, sp, id, ns)) {
|
||||
case (none) {
|
||||
unresolved(e, sp, id, ns_name(ns));
|
||||
fail;
|
||||
}
|
||||
case (some(?d)) {
|
||||
ret d;
|
||||
}
|
||||
}
|
||||
|
||||
fail; // fools the return-checker
|
||||
}
|
||||
|
||||
fn scope_is_fn(&scope sc) -> bool {
|
||||
@ -640,7 +639,6 @@ fn lookup_in_scope(&env e, list[scope] sc, &span sp, &ident id, namespace ns)
|
||||
}
|
||||
}
|
||||
e.sess.bug("reached unreachable code in lookup_in_scope"); // sigh
|
||||
fail;
|
||||
}
|
||||
|
||||
fn lookup_in_ty_params(&ident id, &vec[ast::ty_param] ty_params)
|
||||
@ -790,12 +788,13 @@ fn lookup_in_mod_strict(&env e, def m, &span sp, &ident id,
|
||||
alt (lookup_in_mod(e, m, sp, id, ns, dr)) {
|
||||
case (none) {
|
||||
unresolved(e, sp, id, ns_name(ns));
|
||||
fail;
|
||||
}
|
||||
case (some(?d)) {
|
||||
ret d;
|
||||
}
|
||||
}
|
||||
|
||||
fail; // fools the return-checker
|
||||
}
|
||||
|
||||
fn lookup_in_mod(&env e, def m, &span sp, &ident id, namespace ns, dir dr)
|
||||
@ -855,7 +854,7 @@ fn lookup_import(&env e, def_id defid, namespace ns) -> option::t[def] {
|
||||
case (ns_module) { md } };
|
||||
}
|
||||
}
|
||||
fail;
|
||||
fail; // fools the return-checker
|
||||
}
|
||||
|
||||
|
||||
@ -915,7 +914,6 @@ fn lookup_glob_in_mod(&env e, @indexed_mod info, &span sp,
|
||||
}
|
||||
e.sess.span_err(sp, "'" + id + "' is glob-imported from" +
|
||||
" multiple different modules.");
|
||||
fail;
|
||||
}
|
||||
}
|
||||
// since we don't know what names we have in advance,
|
||||
|
@ -715,7 +715,6 @@ fn type_of(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
|
||||
cx.sess.span_err (sp,
|
||||
"type_of() called on a type with dynamic size: " +
|
||||
ty::ty_to_str(cx.tcx, t));
|
||||
fail;
|
||||
}
|
||||
|
||||
ret type_of_inner(cx, sp, t);
|
||||
@ -937,14 +936,14 @@ fn type_of_inner(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
|
||||
llty = abs_pair;
|
||||
}
|
||||
case (ty::ty_var(_)) {
|
||||
cx.tcx.sess.span_err(sp, "ty_var in trans::type_of");
|
||||
cx.tcx.sess.span_err(sp, "trans::type_of called on ty_var");
|
||||
}
|
||||
case (ty::ty_param(_)) {
|
||||
llty = T_i8();
|
||||
}
|
||||
case (ty::ty_bound_param(_)) {
|
||||
log_err "ty_bound_param in trans::type_of";
|
||||
fail;
|
||||
cx.tcx.sess.span_err(sp,
|
||||
"trans::type_of called on ty_bound_param");
|
||||
}
|
||||
case (ty::ty_type) { llty = T_ptr(T_tydesc(cx.tn)); }
|
||||
}
|
||||
@ -1212,21 +1211,12 @@ fn find_scope_cx(&@block_ctxt cx) -> @block_ctxt {
|
||||
be find_scope_cx(b);
|
||||
}
|
||||
case (parent_none) {
|
||||
fail;
|
||||
cx.fcx.lcx.ccx.sess.bug("trans::find_scope_cx() "
|
||||
+ "called on parentless block_ctxt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn find_outer_scope_cx(&@block_ctxt cx) -> @block_ctxt {
|
||||
auto scope_cx = find_scope_cx(cx);
|
||||
alt (cx.parent) {
|
||||
case (parent_some(?b)) {
|
||||
be find_scope_cx(b);
|
||||
}
|
||||
case (parent_none) {
|
||||
fail;
|
||||
}
|
||||
}
|
||||
fail; // fools the return-checker
|
||||
}
|
||||
|
||||
fn umax(&@block_ctxt cx, ValueRef a, ValueRef b) -> ValueRef {
|
||||
@ -1320,8 +1310,8 @@ fn simplify_type(&@crate_ctxt ccx, &ty::t typ) -> ty::t {
|
||||
// Computes the size of the data part of a non-dynamically-sized tag.
|
||||
fn static_size_of_tag(&@crate_ctxt cx, &span sp, &ty::t t) -> uint {
|
||||
if (ty::type_has_dynamic_size(cx.tcx, t)) {
|
||||
log_err "dynamically sized type passed to static_size_of_tag()";
|
||||
fail;
|
||||
cx.tcx.sess.span_err(sp, "dynamically sized type passed to "
|
||||
+ "static_size_of_tag()");
|
||||
}
|
||||
|
||||
if (cx.tag_sizes.contains_key(t)) {
|
||||
@ -1336,8 +1326,8 @@ fn static_size_of_tag(&@crate_ctxt cx, &span sp, &ty::t t) -> uint {
|
||||
subtys = subtys_;
|
||||
}
|
||||
case (_) {
|
||||
log_err "non-tag passed to static_size_of_tag()";
|
||||
fail;
|
||||
cx.tcx.sess.span_err(sp, "non-tag passed to "
|
||||
+ "static_size_of_tag()");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2570,7 +2560,8 @@ fn make_scalar_cmp_glue(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
|
||||
}
|
||||
case (_) {
|
||||
// Should never get here, because t is scalar.
|
||||
fail;
|
||||
cx.fcx.lcx.ccx.sess.bug("non-scalar type passed to "
|
||||
+ "make_scalar_cmp_glue");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2812,7 +2803,6 @@ fn iter_structural_ty_full(&@block_ctxt cx,
|
||||
j += 1;
|
||||
}
|
||||
}
|
||||
case (_) { fail; }
|
||||
}
|
||||
|
||||
variant_cx.build.Br(next_cx.llbb);
|
||||
@ -2984,7 +2974,6 @@ fn iter_sequence(@block_ctxt cx,
|
||||
cx.fcx.lcx.ccx.sess.bug("unexpected type in " +
|
||||
"trans::iter_sequence: " +
|
||||
ty::ty_to_str(cx.fcx.lcx.ccx.tcx, t));
|
||||
fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3329,7 +3318,6 @@ fn copy_val(&@block_ctxt cx,
|
||||
|
||||
cx.fcx.lcx.ccx.sess.bug("unexpected type in trans::copy_val: " +
|
||||
ty::ty_to_str(cx.fcx.lcx.ccx.tcx, t));
|
||||
fail;
|
||||
}
|
||||
|
||||
// This works like copy_val, except that it deinitializes the source.
|
||||
@ -3367,7 +3355,6 @@ fn move_val(&@block_ctxt cx,
|
||||
|
||||
cx.fcx.lcx.ccx.sess.bug("unexpected type in trans::move_val: " +
|
||||
ty::ty_to_str(cx.fcx.lcx.ccx.tcx, t));
|
||||
fail;
|
||||
}
|
||||
|
||||
|
||||
@ -3490,12 +3477,11 @@ fn trans_unary(&@block_ctxt cx, ast::unop op,
|
||||
ret res(sub.bcx, box);
|
||||
}
|
||||
case (ast::deref) {
|
||||
log_err "deref expressions should have been translated using " +
|
||||
"trans_lval(), not trans_unary()";
|
||||
fail;
|
||||
cx.fcx.lcx.ccx.sess.bug("deref expressions should have been "
|
||||
+ "translated using trans_lval(), not "
|
||||
+ "trans_unary()");
|
||||
}
|
||||
}
|
||||
fail;
|
||||
}
|
||||
|
||||
fn trans_compare(&@block_ctxt cx0, ast::binop op, &ty::t t0,
|
||||
@ -3659,7 +3645,6 @@ fn trans_eager_binop(&@block_ctxt cx, ast::binop op, &ty::t intype,
|
||||
ret trans_compare(cx, op, intype, lhs, rhs);
|
||||
}
|
||||
}
|
||||
fail;
|
||||
}
|
||||
|
||||
fn autoderef(&@block_ctxt cx, ValueRef v, &ty::t t) -> result {
|
||||
@ -3783,7 +3768,6 @@ fn trans_binary(&@block_ctxt cx, ast::binop op,
|
||||
autoderefed_ty(cx.fcx.lcx.ccx, lhty), lhs.val, rhs.val);
|
||||
}
|
||||
}
|
||||
fail;
|
||||
}
|
||||
|
||||
fn join_results(&@block_ctxt parent_cx,
|
||||
@ -4211,7 +4195,6 @@ fn trans_for_each(&@block_ctxt cx,
|
||||
ret res(r.bcx, C_nil());
|
||||
}
|
||||
}
|
||||
fail;
|
||||
}
|
||||
|
||||
|
||||
@ -4325,8 +4308,6 @@ fn trans_pat_match(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
|
||||
ret res(matched_cx, llval);
|
||||
}
|
||||
}
|
||||
|
||||
fail;
|
||||
}
|
||||
|
||||
fn trans_pat_binding(&@block_ctxt cx, &@ast::pat pat,
|
||||
@ -4650,7 +4631,6 @@ fn trans_field(&@block_ctxt cx, &span sp, ValueRef v, &ty::t t0,
|
||||
}
|
||||
case (_) {cx.fcx.lcx.ccx.sess.unimpl("field variant in trans_field");}
|
||||
}
|
||||
fail;
|
||||
}
|
||||
|
||||
fn trans_index(&@block_ctxt cx, &span sp, &@ast::expr base,
|
||||
@ -4747,7 +4727,9 @@ fn trans_lval(&@block_ctxt cx, &@ast::expr e) -> lval_result {
|
||||
}
|
||||
case (_) {
|
||||
// Shouldn't happen.
|
||||
fail;
|
||||
cx.fcx.lcx.ccx.sess.bug(
|
||||
"trans_lval called on expr_self_method in a context"
|
||||
+ "without llself");
|
||||
}
|
||||
|
||||
}
|
||||
@ -4758,7 +4740,6 @@ fn trans_lval(&@block_ctxt cx, &@ast::expr e) -> lval_result {
|
||||
+ pretty::pprust::expr_to_str(e));
|
||||
}
|
||||
}
|
||||
fail;
|
||||
}
|
||||
|
||||
fn int_cast(&@block_ctxt bcx, TypeRef lldsttype, TypeRef llsrctype,
|
||||
@ -5898,7 +5879,6 @@ fn trans_log(int lvl, &@block_ctxt cx, &@ast::expr e) -> result {
|
||||
cx.fcx.lcx.ccx.sess.span_err(e.span,
|
||||
"log called on unsupported type " +
|
||||
ty::ty_to_str(cx.fcx.lcx.ccx.tcx, e_ty));
|
||||
fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6017,7 +5997,9 @@ fn trans_break_cont(&@block_ctxt cx, bool to_end) -> result {
|
||||
}
|
||||
}
|
||||
}
|
||||
fail;
|
||||
|
||||
// If we get here without returning, it's a bug
|
||||
cx.fcx.lcx.ccx.sess.bug("in trans::trans_break_cont()");
|
||||
}
|
||||
|
||||
fn trans_break(&@block_ctxt cx) -> result {
|
||||
@ -6085,7 +6067,6 @@ fn trans_port(&@block_ctxt cx, &ast::ann ann) -> result {
|
||||
}
|
||||
case (_) {
|
||||
cx.fcx.lcx.ccx.sess.bug("non-port type in trans_port");
|
||||
fail;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6310,7 +6291,6 @@ fn trans_send(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
|
||||
}
|
||||
case (_) {
|
||||
bcx.fcx.lcx.ccx.sess.bug("non-chan type in trans_send");
|
||||
fail;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6432,7 +6412,6 @@ fn trans_anon_obj(&@block_ctxt cx, &span sp,
|
||||
// TODO: everything else.
|
||||
|
||||
cx.fcx.lcx.ccx.sess.unimpl("support for anonymous objects");
|
||||
fail;
|
||||
}
|
||||
|
||||
fn init_local(&@block_ctxt cx, &@ast::local local) -> result {
|
||||
@ -6917,7 +6896,6 @@ fn arg_tys_of_fn(&@crate_ctxt ccx, ast::ann ann) -> vec[ty::arg] {
|
||||
ret arg_tys;
|
||||
}
|
||||
}
|
||||
fail;
|
||||
}
|
||||
|
||||
fn ret_ty_of_fn_ty(&@crate_ctxt ccx, ty::t t) -> ty::t {
|
||||
@ -6926,7 +6904,6 @@ fn ret_ty_of_fn_ty(&@crate_ctxt ccx, ty::t t) -> ty::t {
|
||||
ret ret_ty;
|
||||
}
|
||||
}
|
||||
fail;
|
||||
}
|
||||
|
||||
|
||||
@ -7515,7 +7492,6 @@ fn decl_fn_and_pair(&@crate_ctxt ccx, &span sp,
|
||||
}
|
||||
case (_) {
|
||||
ccx.sess.bug("decl_fn_and_pair(): fn item doesn't have fn type!");
|
||||
fail;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7558,7 +7534,6 @@ fn native_fn_ty_param_count(&@crate_ctxt cx, &ast::def_id id) -> uint {
|
||||
case (ast::native_item_ty(_,_)) {
|
||||
cx.sess.bug("decl_native_fn_and_pair(): native fn isn't " +
|
||||
"actually a fn?!");
|
||||
fail;
|
||||
}
|
||||
case (ast::native_item_fn(_, _, _, ?tps, _, _)) {
|
||||
count = vec::len[ast::ty_param](tps);
|
||||
@ -7574,7 +7549,6 @@ fn native_fn_wrapper_type(&@crate_ctxt cx, &span sp, uint ty_param_count,
|
||||
ret type_of_fn(cx, sp, ast::proto_fn, args, out, ty_param_count);
|
||||
}
|
||||
}
|
||||
fail;
|
||||
}
|
||||
|
||||
fn decl_native_fn_and_pair(&@crate_ctxt ccx,
|
||||
@ -8013,7 +7987,6 @@ fn find_main_fn(&@crate_ctxt cx) -> ValueRef {
|
||||
cx.sess.err("multiple main fns found");
|
||||
}
|
||||
}
|
||||
fail;
|
||||
}
|
||||
|
||||
fn trans_main_fn(@local_ctxt cx, ValueRef crate_map) {
|
||||
|
@ -1895,7 +1895,6 @@ fn field_idx(&session::session sess, &span sp,
|
||||
i += 1u;
|
||||
}
|
||||
sess.span_err(sp, "unknown field '" + id + "' of record");
|
||||
fail;
|
||||
}
|
||||
|
||||
fn method_idx(&session::session sess, &span sp,
|
||||
@ -1908,7 +1907,6 @@ fn method_idx(&session::session sess, &span sp,
|
||||
i += 1u;
|
||||
}
|
||||
sess.span_err(sp, "unknown method '" + id + "' of obj");
|
||||
fail;
|
||||
}
|
||||
|
||||
fn sort_methods(&vec[method] meths) -> vec[method] {
|
||||
@ -2904,7 +2902,6 @@ fn tag_variants(&ctxt cx, &ast::def_id id) -> vec[variant_info] {
|
||||
}
|
||||
}
|
||||
}
|
||||
fail; // not reached
|
||||
}
|
||||
|
||||
// Returns information about the tag variant with the given ID:
|
||||
|
@ -102,7 +102,6 @@ fn substitute_ty_params(&@crate_ctxt ccx,
|
||||
uint::to_str(ty_param_count, 10u) +
|
||||
" type parameter(s) but found " +
|
||||
uint::to_str(supplied_len, 10u) + " parameter(s)");
|
||||
fail;
|
||||
}
|
||||
|
||||
if (!ty::type_contains_bound_params(ccx.tcx, typ)) {
|
||||
@ -162,13 +161,11 @@ fn ty_param_count_and_ty_for_def(&@fn_ctxt fcx, &span sp, &ast::def defn)
|
||||
|
||||
case (ast::def_ty(_)) {
|
||||
fcx.ccx.tcx.sess.span_err(sp, "expected value but found type");
|
||||
fail;
|
||||
}
|
||||
|
||||
case (_) {
|
||||
// FIXME: handle other names.
|
||||
fcx.ccx.tcx.sess.unimpl("definition variant");
|
||||
fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -332,7 +329,7 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
|
||||
case (_) {
|
||||
tcx.sess.span_err(ast_ty.span,
|
||||
"found type name used as a variable");
|
||||
fail; }
|
||||
}
|
||||
}
|
||||
|
||||
cname = some(path_to_str(path));
|
||||
@ -1041,7 +1038,6 @@ mod demand {
|
||||
|
||||
// TODO: In the future, try returning "expected", reporting
|
||||
// the error, and continue.
|
||||
fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1437,7 +1433,6 @@ mod pushdown {
|
||||
scx.fcx.ccx.tcx.sess.span_unimpl(e.span,
|
||||
#fmt("type unification for expression variant: %s",
|
||||
pretty::pprust::expr_to_str(e)));
|
||||
fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1468,7 +1463,6 @@ mod writeback {
|
||||
case (none) {
|
||||
fcx.ccx.tcx.sess.span_err(sp,
|
||||
"unable to determine type of local: " + local.ident);
|
||||
fail;
|
||||
}
|
||||
case (some(?lt)) {
|
||||
local_ty = lt;
|
||||
@ -1774,7 +1768,6 @@ fn check_expr(&@stmt_ctxt scx, &@ast::expr expr) {
|
||||
+ " instead having: " +
|
||||
ty_to_str(scx.fcx.ccx.tcx,
|
||||
expr_ty(scx.fcx.ccx.tcx, f)));
|
||||
fail;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1903,7 +1896,6 @@ fn check_expr(&@stmt_ctxt scx, &@ast::expr expr) {
|
||||
if (vec::len[@ast::ty](pth.node.types) > 0u) {
|
||||
scx.fcx.ccx.tcx.sess.span_err(expr.span,
|
||||
"this kind of value does not take type parameters");
|
||||
fail;
|
||||
}
|
||||
|
||||
write::ty_only_fixup(scx, old_ann.id, tpt._1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user