diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-07-29 20:51:18 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-07-29 20:54:44 +0200 |
| commit | c34d74315f8d336c91c00819c4c12cd655990a59 (patch) | |
| tree | bc20eed21c7406a23b42d8610baf3cf0b88b554c /src/comp | |
| parent | aa3b89610e081b3b58a3d4acb5201c0d6ea200c6 (diff) | |
| download | rust-c34d74315f8d336c91c00819c4c12cd655990a59.tar.gz rust-c34d74315f8d336c91c00819c4c12cd655990a59.zip | |
Remove unreachable statements
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/back/link.rs | 1 | ||||
| -rw-r--r-- | src/comp/driver/rustc.rs | 2 | ||||
| -rw-r--r-- | src/comp/middle/trans_comm.rs | 2 | ||||
| -rw-r--r-- | src/comp/middle/ty.rs | 17 | ||||
| -rw-r--r-- | src/comp/syntax/ast.rs | 1 | ||||
| -rw-r--r-- | src/comp/syntax/ext/base.rs | 7 | ||||
| -rw-r--r-- | src/comp/syntax/ext/simplext.rs | 10 | ||||
| -rw-r--r-- | src/comp/syntax/parse/lexer.rs | 1 | ||||
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 17 |
9 files changed, 25 insertions, 33 deletions
diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs index 7a933aa20f8..98f540de7e8 100644 --- a/src/comp/back/link.rs +++ b/src/comp/back/link.rs @@ -36,7 +36,6 @@ fn llvm_err(sess: session::session, msg: str) { if buf as uint == 0u { sess.fatal(msg); } else { sess.fatal(msg + ": " + str::str_from_cstr(buf)); } - fail; } fn link_intrinsics(sess: session::session, llmod: ModuleRef) { diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index 25b54869448..d58968c6546 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -94,7 +94,7 @@ fn parse_input(sess: session::session, cfg: &ast::crate_cfg, input: str) -> } else if (str::ends_with(input, ".rs")) { parser::parse_crate_from_source_file(input, cfg, sess.get_parse_sess()) - } else { sess.fatal("unknown input file type: " + input); fail }; + } else { sess.fatal("unknown input file type: " + input) }; } fn time[T](do_it: bool, what: str, thunk: fn() -> T ) -> T { diff --git a/src/comp/middle/trans_comm.rs b/src/comp/middle/trans_comm.rs index 133e2a33c59..2fc24f8cb52 100644 --- a/src/comp/middle/trans_comm.rs +++ b/src/comp/middle/trans_comm.rs @@ -206,6 +206,7 @@ fn trans_send(cx: &@block_ctxt, lhs: &@ast::expr, rhs: &@ast::expr, let data = trans_lval(bcx, rhs); bcx = data.res.bcx; let chan_ty = node_id_type(cx.fcx.lcx.ccx, id); + let unit_ty; alt ty::struct(cx.fcx.lcx.ccx.tcx, chan_ty) { ty::ty_chan(t) { unit_ty = t; } _ { bcx.fcx.lcx.ccx.sess.bug("non-chan type in trans_send"); } @@ -223,7 +224,6 @@ fn trans_send(cx: &@block_ctxt, lhs: &@ast::expr, rhs: &@ast::expr, bcx = zero_alloca(bcx, data_alloc.val, unit_ty).bcx; ret rslt(bcx, chn.val); - let unit_ty; } fn trans_recv(cx: &@block_ctxt, lhs: &@ast::expr, rhs: &@ast::expr, diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index a3b043820d6..9e93c40b60c 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1820,26 +1820,30 @@ fn ty_fn_args(cx: &ctxt, fty: &t) -> arg[] { alt struct(cx, fty) { ty::ty_fn(_, a, _, _, _) { ret a; } ty::ty_native_fn(_, a, _) { ret a; } + _ { cx.sess.bug("ty_fn_args() called on non-fn type"); } } - cx.sess.bug("ty_fn_args() called on non-fn type"); } fn ty_fn_proto(cx: &ctxt, fty: &t) -> ast::proto { - alt struct(cx, fty) { ty::ty_fn(p, _, _, _, _) { ret p; } } - cx.sess.bug("ty_fn_proto() called on non-fn type"); + alt struct(cx, fty) { + ty::ty_fn(p, _, _, _, _) { ret p; } + _ { cx.sess.bug("ty_fn_proto() called on non-fn type"); } + } } fn ty_fn_abi(cx: &ctxt, fty: &t) -> ast::native_abi { - alt struct(cx, fty) { ty::ty_native_fn(a, _, _) { ret a; } } - cx.sess.bug("ty_fn_abi() called on non-native-fn type"); + alt struct(cx, fty) { + ty::ty_native_fn(a, _, _) { ret a; } + _ { cx.sess.bug("ty_fn_abi() called on non-native-fn type"); } + } } fn ty_fn_ret(cx: &ctxt, fty: &t) -> t { alt struct(cx, fty) { ty::ty_fn(_, _, r, _, _) { ret r; } ty::ty_native_fn(_, _, r) { ret r; } + _ { cx.sess.bug("ty_fn_ret() called on non-fn type"); } } - cx.sess.bug("ty_fn_ret() called on non-fn type"); } fn is_fn_ty(cx: &ctxt, fty: &t) -> bool { @@ -2707,7 +2711,6 @@ fn type_err_to_str(err: &ty::type_err) -> str { terr_mode_mismatch(e_mode, a_mode) { ret "expected argument mode " + mode_str_1(e_mode) + " but found " + mode_str_1(a_mode); - fail; } terr_constr_len(e_len, a_len) { ret "Expected a type with " + uint::str(e_len) + diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs index d71a2b0b168..fc2d64ddb49 100644 --- a/src/comp/syntax/ast.rs +++ b/src/comp/syntax/ast.rs @@ -81,7 +81,6 @@ fn def_id_of_def(d: def) -> def_id { def_native_fn(id) { ret id; } def_upvar(id, _) { ret id; } } - fail; } // The set of meta_items that define the compilation environment of the crate, diff --git a/src/comp/syntax/ext/base.rs b/src/comp/syntax/ext/base.rs index b83a03c4343..06f998e71e8 100644 --- a/src/comp/syntax/ext/base.rs +++ b/src/comp/syntax/ext/base.rs @@ -54,13 +54,12 @@ fn mk_ctxt(sess: &session) -> ext_ctxt { sess.span_err(sp, "unimplemented " + msg); fail; } - let ext_span_unimpl = bind ext_span_unimpl_(sess, _, _); + let ext_span_bug = bind ext_span_bug_(sess, _, _); fn ext_span_bug_(sess: &session, sp: span, msg: str) -> ! { sess.span_bug(sp, msg); - fail; } - let ext_span_bug = bind ext_span_bug_(sess, _, _); - fn ext_bug_(sess: &session, msg: str) -> ! { sess.bug(msg); fail; } + let ext_span_unimpl = bind ext_span_unimpl_(sess, _, _); + fn ext_bug_(sess: &session, msg: str) -> ! { sess.bug(msg); } let ext_bug = bind ext_bug_(sess, _); diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs index 4fa169545e2..d7de173e5e3 100644 --- a/src/comp/syntax/ext/simplext.rs +++ b/src/comp/syntax/ext/simplext.rs @@ -452,7 +452,7 @@ fn p_t_s_rec(cx: &ext_ctxt, m: &matchable, s: &selector, b: &binders) { match_expr(e) { if e == pat { some(leaf(match_exact)) } else { none } } - _ { cx.bug("broken traversal in p_t_s_r"); fail } + _ { cx.bug("broken traversal in p_t_s_r") } } } b.literal_ast_matchers += ~[bind select(cx, _, e)]; @@ -488,7 +488,7 @@ fn p_t_s_r_path(cx: &ext_ctxt, p: &path, s: &selector, b: &binders) { fn select(cx: &ext_ctxt, m: &matchable) -> match_result { ret alt m { match_expr(e) { some(leaf(specialize_match(m))) } - _ { cx.bug("broken traversal in p_t_s_r"); fail } + _ { cx.bug("broken traversal in p_t_s_r") } } } if b.real_binders.contains_key(p_id) { @@ -517,7 +517,7 @@ fn p_t_s_r_mac(cx: &ext_ctxt, mac: &ast::mac, s: &selector, b: &binders) { match_expr(e) { alt e.node { expr_mac(mac) { fn_m(mac) } _ { none } } } - _ { cx.bug("broken traversal in p_t_s_r"); fail } + _ { cx.bug("broken traversal in p_t_s_r") } } } fn no_des(cx: &ext_ctxt, sp: &span, syn: &str) -> ! { @@ -593,7 +593,7 @@ fn p_t_s_r_ellipses(cx: &ext_ctxt, repeat_me: @expr, s: &selector, _ { none } } } - _ { cx.bug("broken traversal in p_t_s_r"); fail } + _ { cx.bug("broken traversal in p_t_s_r") } } } p_t_s_rec(cx, match_expr(repeat_me), @@ -633,7 +633,7 @@ fn p_t_s_r_actual_vector(cx: &ext_ctxt, elts: (@expr)[], s: &selector, _ { none } } } - _ { cx.bug("broken traversal in p_t_s_r"); fail } + _ { cx.bug("broken traversal in p_t_s_r") } } } p_t_s_rec(cx, match_expr(elts.(idx)), diff --git a/src/comp/syntax/parse/lexer.rs b/src/comp/syntax/parse/lexer.rs index b11e7aa5d85..bf91dfc8a9c 100644 --- a/src/comp/syntax/parse/lexer.rs +++ b/src/comp/syntax/parse/lexer.rs @@ -541,7 +541,6 @@ fn next_token_inner(rdr: &reader) -> token::token { '%' { ret binop(rdr, token::PERCENT); } c { rdr.err(#fmt("unkown start of token: %d", c as int)); fail; } } - fail; } tag cmnt_style { diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 6c3f04d1c87..3fba6f614f0 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -211,7 +211,7 @@ fn spanned[T](lo: uint, hi: uint, node: &T) -> spanned[T] { fn parse_ident(p: &parser) -> ast::ident { alt p.peek() { token::IDENT(i, _) { p.bump(); ret p.get_str(i); } - _ { p.fatal("expecting ident"); fail; } + _ { p.fatal("expecting ident"); } } } @@ -331,7 +331,6 @@ fn parse_ty_obj(p: &parser, hi: &mutable uint) -> ast::ty_ { constrs: constrs}); } } - fail; } let meths = parse_seq(token::LBRACE, token::RBRACE, none, parse_method_sig, p); @@ -589,7 +588,7 @@ fn parse_ty(p: &parser) -> @ast::ty { let path = parse_path(p); t = ast::ty_path(path, p.get_id()); hi = path.span.hi; - } else { p.fatal("expecting type"); t = ast::ty_nil; fail; } + } else { p.fatal("expecting type"); } ret parse_ty_postfix(t, p); } @@ -1570,10 +1569,9 @@ fn parse_source_stmt(p: &parser) -> @ast::stmt { let e = parse_expr(p); ret @spanned(lo, e.span.hi, ast::stmt_expr(e, p.get_id())); } + _ { p.fatal("expected statement"); } } } - p.fatal("expected statement"); - fail; } fn stmt_to_expr(stmt: @ast::stmt) -> option::t[@ast::expr] { @@ -1669,7 +1667,6 @@ fn parse_block_tail(p: &parser, lo: uint) -> ast::blk { p.fatal("expected ';' or '}' after " + "expression but found " + token::to_str(p.get_reader(), t)); - fail; } stmts += ~[stmt]; } @@ -1933,7 +1930,7 @@ fn parse_native_item(p: &parser, attrs: &ast::attribute[]) -> ret parse_item_native_type(p, attrs); } else if (eat_word(p, "fn")) { ret parse_item_native_fn(p, attrs); - } else { unexpected(p, p.peek()); fail; } + } else { unexpected(p, p.peek()); } } fn parse_native_mod_items(p: &parser, native_name: &str, abi: ast::native_abi, @@ -1971,7 +1968,7 @@ fn parse_item_native_mod(p: &parser, attrs: &ast::attribute[]) -> @ast::item { abi = ast::native_abi_rust_intrinsic; } else if (str::eq(t, "x86stdcall")) { abi = ast::native_abi_x86stdcall; - } else { p.fatal("unsupported abi: " + t); fail; } + } else { p.fatal("unsupported abi: " + t); } } expect_word(p, "mod"); let id = parse_ident(p); @@ -2071,7 +2068,6 @@ fn parse_auth(p: &parser) -> ast::_auth { if eat_word(p, "unsafe") { ret ast::auth_unsafe; } else { unexpected(p, p.peek()); } - fail; } fn parse_item(p: &parser, attrs: &ast::attribute[]) -> option::t[@ast::item] { @@ -2260,7 +2256,6 @@ fn parse_full_import_name(p: &parser, def_ident: ast::ident) -> } _ { p.fatal("expecting an identifier"); } } - fail; } fn parse_import(p: &parser) -> ast::view_item_ { @@ -2277,7 +2272,6 @@ fn parse_import(p: &parser) -> ast::view_item_ { } _ { p.fatal("expecting an identifier"); } } - fail; } fn parse_export(p: &parser) -> ast::view_item_ { @@ -2307,7 +2301,6 @@ fn is_view_item(p: &parser) -> bool { } _ { ret false; } } - ret false; } fn parse_view(p: &parser) -> (@ast::view_item)[] { |
