Remove unreachable statements
This commit is contained in:
parent
aa3b89610e
commit
c34d74315f
9 changed files with 25 additions and 33 deletions
|
@ -36,7 +36,6 @@ fn llvm_err(sess: session::session, msg: str) {
|
||||||
if buf as uint == 0u {
|
if buf as uint == 0u {
|
||||||
sess.fatal(msg);
|
sess.fatal(msg);
|
||||||
} else { sess.fatal(msg + ": " + str::str_from_cstr(buf)); }
|
} else { sess.fatal(msg + ": " + str::str_from_cstr(buf)); }
|
||||||
fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn link_intrinsics(sess: session::session, llmod: ModuleRef) {
|
fn link_intrinsics(sess: session::session, llmod: ModuleRef) {
|
||||||
|
|
|
@ -94,7 +94,7 @@ fn parse_input(sess: session::session, cfg: &ast::crate_cfg, input: str) ->
|
||||||
} else if (str::ends_with(input, ".rs")) {
|
} else if (str::ends_with(input, ".rs")) {
|
||||||
parser::parse_crate_from_source_file(input, cfg,
|
parser::parse_crate_from_source_file(input, cfg,
|
||||||
sess.get_parse_sess())
|
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 {
|
fn time[T](do_it: bool, what: str, thunk: fn() -> T ) -> T {
|
||||||
|
|
|
@ -206,6 +206,7 @@ fn trans_send(cx: &@block_ctxt, lhs: &@ast::expr, rhs: &@ast::expr,
|
||||||
let data = trans_lval(bcx, rhs);
|
let data = trans_lval(bcx, rhs);
|
||||||
bcx = data.res.bcx;
|
bcx = data.res.bcx;
|
||||||
let chan_ty = node_id_type(cx.fcx.lcx.ccx, id);
|
let chan_ty = node_id_type(cx.fcx.lcx.ccx, id);
|
||||||
|
let unit_ty;
|
||||||
alt ty::struct(cx.fcx.lcx.ccx.tcx, chan_ty) {
|
alt ty::struct(cx.fcx.lcx.ccx.tcx, chan_ty) {
|
||||||
ty::ty_chan(t) { unit_ty = t; }
|
ty::ty_chan(t) { unit_ty = t; }
|
||||||
_ { bcx.fcx.lcx.ccx.sess.bug("non-chan type in trans_send"); }
|
_ { 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;
|
bcx = zero_alloca(bcx, data_alloc.val, unit_ty).bcx;
|
||||||
|
|
||||||
ret rslt(bcx, chn.val);
|
ret rslt(bcx, chn.val);
|
||||||
let unit_ty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trans_recv(cx: &@block_ctxt, lhs: &@ast::expr, rhs: &@ast::expr,
|
fn trans_recv(cx: &@block_ctxt, lhs: &@ast::expr, rhs: &@ast::expr,
|
||||||
|
|
|
@ -1820,26 +1820,30 @@ fn ty_fn_args(cx: &ctxt, fty: &t) -> arg[] {
|
||||||
alt struct(cx, fty) {
|
alt struct(cx, fty) {
|
||||||
ty::ty_fn(_, a, _, _, _) { ret a; }
|
ty::ty_fn(_, a, _, _, _) { ret a; }
|
||||||
ty::ty_native_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 {
|
fn ty_fn_proto(cx: &ctxt, fty: &t) -> ast::proto {
|
||||||
alt struct(cx, fty) { ty::ty_fn(p, _, _, _, _) { ret p; } }
|
alt struct(cx, fty) {
|
||||||
cx.sess.bug("ty_fn_proto() called on non-fn type");
|
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 {
|
fn ty_fn_abi(cx: &ctxt, fty: &t) -> ast::native_abi {
|
||||||
alt struct(cx, fty) { ty::ty_native_fn(a, _, _) { ret a; } }
|
alt struct(cx, fty) {
|
||||||
cx.sess.bug("ty_fn_abi() called on non-native-fn type");
|
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 {
|
fn ty_fn_ret(cx: &ctxt, fty: &t) -> t {
|
||||||
alt struct(cx, fty) {
|
alt struct(cx, fty) {
|
||||||
ty::ty_fn(_, _, r, _, _) { ret r; }
|
ty::ty_fn(_, _, r, _, _) { ret r; }
|
||||||
ty::ty_native_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 {
|
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) {
|
terr_mode_mismatch(e_mode, a_mode) {
|
||||||
ret "expected argument mode " + mode_str_1(e_mode) + " but found " +
|
ret "expected argument mode " + mode_str_1(e_mode) + " but found " +
|
||||||
mode_str_1(a_mode);
|
mode_str_1(a_mode);
|
||||||
fail;
|
|
||||||
}
|
}
|
||||||
terr_constr_len(e_len, a_len) {
|
terr_constr_len(e_len, a_len) {
|
||||||
ret "Expected a type with " + uint::str(e_len) +
|
ret "Expected a type with " + uint::str(e_len) +
|
||||||
|
|
|
@ -81,7 +81,6 @@ fn def_id_of_def(d: def) -> def_id {
|
||||||
def_native_fn(id) { ret id; }
|
def_native_fn(id) { ret id; }
|
||||||
def_upvar(id, _) { ret id; }
|
def_upvar(id, _) { ret id; }
|
||||||
}
|
}
|
||||||
fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The set of meta_items that define the compilation environment of the crate,
|
// The set of meta_items that define the compilation environment of the crate,
|
||||||
|
|
|
@ -54,13 +54,12 @@ fn mk_ctxt(sess: &session) -> ext_ctxt {
|
||||||
sess.span_err(sp, "unimplemented " + msg);
|
sess.span_err(sp, "unimplemented " + msg);
|
||||||
fail;
|
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) -> ! {
|
fn ext_span_bug_(sess: &session, sp: span, msg: str) -> ! {
|
||||||
sess.span_bug(sp, msg);
|
sess.span_bug(sp, msg);
|
||||||
fail;
|
|
||||||
}
|
}
|
||||||
let ext_span_bug = bind ext_span_bug_(sess, _, _);
|
let ext_span_unimpl = bind ext_span_unimpl_(sess, _, _);
|
||||||
fn ext_bug_(sess: &session, msg: str) -> ! { sess.bug(msg); fail; }
|
fn ext_bug_(sess: &session, msg: str) -> ! { sess.bug(msg); }
|
||||||
let ext_bug = bind ext_bug_(sess, _);
|
let ext_bug = bind ext_bug_(sess, _);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -452,7 +452,7 @@ fn p_t_s_rec(cx: &ext_ctxt, m: &matchable, s: &selector, b: &binders) {
|
||||||
match_expr(e) {
|
match_expr(e) {
|
||||||
if e == pat { some(leaf(match_exact)) } else { none }
|
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)];
|
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 {
|
fn select(cx: &ext_ctxt, m: &matchable) -> match_result {
|
||||||
ret alt m {
|
ret alt m {
|
||||||
match_expr(e) { some(leaf(specialize_match(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) {
|
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) {
|
match_expr(e) {
|
||||||
alt e.node { expr_mac(mac) { fn_m(mac) } _ { none } }
|
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) -> ! {
|
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 }
|
_ { 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),
|
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 }
|
_ { 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)),
|
p_t_s_rec(cx, match_expr(elts.(idx)),
|
||||||
|
|
|
@ -541,7 +541,6 @@ fn next_token_inner(rdr: &reader) -> token::token {
|
||||||
'%' { ret binop(rdr, token::PERCENT); }
|
'%' { ret binop(rdr, token::PERCENT); }
|
||||||
c { rdr.err(#fmt("unkown start of token: %d", c as int)); fail; }
|
c { rdr.err(#fmt("unkown start of token: %d", c as int)); fail; }
|
||||||
}
|
}
|
||||||
fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tag cmnt_style {
|
tag cmnt_style {
|
||||||
|
|
|
@ -211,7 +211,7 @@ fn spanned[T](lo: uint, hi: uint, node: &T) -> spanned[T] {
|
||||||
fn parse_ident(p: &parser) -> ast::ident {
|
fn parse_ident(p: &parser) -> ast::ident {
|
||||||
alt p.peek() {
|
alt p.peek() {
|
||||||
token::IDENT(i, _) { p.bump(); ret p.get_str(i); }
|
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});
|
constrs: constrs});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fail;
|
|
||||||
}
|
}
|
||||||
let meths =
|
let meths =
|
||||||
parse_seq(token::LBRACE, token::RBRACE, none, parse_method_sig, p);
|
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);
|
let path = parse_path(p);
|
||||||
t = ast::ty_path(path, p.get_id());
|
t = ast::ty_path(path, p.get_id());
|
||||||
hi = path.span.hi;
|
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);
|
ret parse_ty_postfix(t, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1570,10 +1569,9 @@ fn parse_source_stmt(p: &parser) -> @ast::stmt {
|
||||||
let e = parse_expr(p);
|
let e = parse_expr(p);
|
||||||
ret @spanned(lo, e.span.hi, ast::stmt_expr(e, p.get_id()));
|
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] {
|
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 " +
|
p.fatal("expected ';' or '}' after " +
|
||||||
"expression but found " +
|
"expression but found " +
|
||||||
token::to_str(p.get_reader(), t));
|
token::to_str(p.get_reader(), t));
|
||||||
fail;
|
|
||||||
}
|
}
|
||||||
stmts += ~[stmt];
|
stmts += ~[stmt];
|
||||||
}
|
}
|
||||||
|
@ -1933,7 +1930,7 @@ fn parse_native_item(p: &parser, attrs: &ast::attribute[]) ->
|
||||||
ret parse_item_native_type(p, attrs);
|
ret parse_item_native_type(p, attrs);
|
||||||
} else if (eat_word(p, "fn")) {
|
} else if (eat_word(p, "fn")) {
|
||||||
ret parse_item_native_fn(p, attrs);
|
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,
|
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;
|
abi = ast::native_abi_rust_intrinsic;
|
||||||
} else if (str::eq(t, "x86stdcall")) {
|
} else if (str::eq(t, "x86stdcall")) {
|
||||||
abi = ast::native_abi_x86stdcall;
|
abi = ast::native_abi_x86stdcall;
|
||||||
} else { p.fatal("unsupported abi: " + t); fail; }
|
} else { p.fatal("unsupported abi: " + t); }
|
||||||
}
|
}
|
||||||
expect_word(p, "mod");
|
expect_word(p, "mod");
|
||||||
let id = parse_ident(p);
|
let id = parse_ident(p);
|
||||||
|
@ -2071,7 +2068,6 @@ fn parse_auth(p: &parser) -> ast::_auth {
|
||||||
if eat_word(p, "unsafe") {
|
if eat_word(p, "unsafe") {
|
||||||
ret ast::auth_unsafe;
|
ret ast::auth_unsafe;
|
||||||
} else { unexpected(p, p.peek()); }
|
} else { unexpected(p, p.peek()); }
|
||||||
fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_item(p: &parser, attrs: &ast::attribute[]) -> option::t[@ast::item] {
|
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"); }
|
_ { p.fatal("expecting an identifier"); }
|
||||||
}
|
}
|
||||||
fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_import(p: &parser) -> ast::view_item_ {
|
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"); }
|
_ { p.fatal("expecting an identifier"); }
|
||||||
}
|
}
|
||||||
fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_export(p: &parser) -> ast::view_item_ {
|
fn parse_export(p: &parser) -> ast::view_item_ {
|
||||||
|
@ -2307,7 +2301,6 @@ fn is_view_item(p: &parser) -> bool {
|
||||||
}
|
}
|
||||||
_ { ret false; }
|
_ { ret false; }
|
||||||
}
|
}
|
||||||
ret false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_view(p: &parser) -> (@ast::view_item)[] {
|
fn parse_view(p: &parser) -> (@ast::view_item)[] {
|
||||||
|
|
Loading…
Reference in a new issue