Skip to content

Commit c34d743

Browse files
committed
Remove unreachable statements
1 parent aa3b896 commit c34d743

File tree

9 files changed

+25
-33
lines changed

9 files changed

+25
-33
lines changed

src/comp/back/link.rs

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ fn llvm_err(sess: session::session, msg: str) {
3636
if buf as uint == 0u {
3737
sess.fatal(msg);
3838
} else { sess.fatal(msg + ": " + str::str_from_cstr(buf)); }
39-
fail;
4039
}
4140

4241
fn link_intrinsics(sess: session::session, llmod: ModuleRef) {

src/comp/driver/rustc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn parse_input(sess: session::session, cfg: &ast::crate_cfg, input: str) ->
9494
} else if (str::ends_with(input, ".rs")) {
9595
parser::parse_crate_from_source_file(input, cfg,
9696
sess.get_parse_sess())
97-
} else { sess.fatal("unknown input file type: " + input); fail };
97+
} else { sess.fatal("unknown input file type: " + input) };
9898
}
9999

100100
fn time[T](do_it: bool, what: str, thunk: fn() -> T ) -> T {

src/comp/middle/trans_comm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ fn trans_send(cx: &@block_ctxt, lhs: &@ast::expr, rhs: &@ast::expr,
206206
let data = trans_lval(bcx, rhs);
207207
bcx = data.res.bcx;
208208
let chan_ty = node_id_type(cx.fcx.lcx.ccx, id);
209+
let unit_ty;
209210
alt ty::struct(cx.fcx.lcx.ccx.tcx, chan_ty) {
210211
ty::ty_chan(t) { unit_ty = t; }
211212
_ { 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,
223224
bcx = zero_alloca(bcx, data_alloc.val, unit_ty).bcx;
224225

225226
ret rslt(bcx, chn.val);
226-
let unit_ty;
227227
}
228228

229229
fn trans_recv(cx: &@block_ctxt, lhs: &@ast::expr, rhs: &@ast::expr,

src/comp/middle/ty.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -1820,26 +1820,30 @@ fn ty_fn_args(cx: &ctxt, fty: &t) -> arg[] {
18201820
alt struct(cx, fty) {
18211821
ty::ty_fn(_, a, _, _, _) { ret a; }
18221822
ty::ty_native_fn(_, a, _) { ret a; }
1823+
_ { cx.sess.bug("ty_fn_args() called on non-fn type"); }
18231824
}
1824-
cx.sess.bug("ty_fn_args() called on non-fn type");
18251825
}
18261826

18271827
fn ty_fn_proto(cx: &ctxt, fty: &t) -> ast::proto {
1828-
alt struct(cx, fty) { ty::ty_fn(p, _, _, _, _) { ret p; } }
1829-
cx.sess.bug("ty_fn_proto() called on non-fn type");
1828+
alt struct(cx, fty) {
1829+
ty::ty_fn(p, _, _, _, _) { ret p; }
1830+
_ { cx.sess.bug("ty_fn_proto() called on non-fn type"); }
1831+
}
18301832
}
18311833

18321834
fn ty_fn_abi(cx: &ctxt, fty: &t) -> ast::native_abi {
1833-
alt struct(cx, fty) { ty::ty_native_fn(a, _, _) { ret a; } }
1834-
cx.sess.bug("ty_fn_abi() called on non-native-fn type");
1835+
alt struct(cx, fty) {
1836+
ty::ty_native_fn(a, _, _) { ret a; }
1837+
_ { cx.sess.bug("ty_fn_abi() called on non-native-fn type"); }
1838+
}
18351839
}
18361840

18371841
fn ty_fn_ret(cx: &ctxt, fty: &t) -> t {
18381842
alt struct(cx, fty) {
18391843
ty::ty_fn(_, _, r, _, _) { ret r; }
18401844
ty::ty_native_fn(_, _, r) { ret r; }
1845+
_ { cx.sess.bug("ty_fn_ret() called on non-fn type"); }
18411846
}
1842-
cx.sess.bug("ty_fn_ret() called on non-fn type");
18431847
}
18441848

18451849
fn is_fn_ty(cx: &ctxt, fty: &t) -> bool {
@@ -2707,7 +2711,6 @@ fn type_err_to_str(err: &ty::type_err) -> str {
27072711
terr_mode_mismatch(e_mode, a_mode) {
27082712
ret "expected argument mode " + mode_str_1(e_mode) + " but found " +
27092713
mode_str_1(a_mode);
2710-
fail;
27112714
}
27122715
terr_constr_len(e_len, a_len) {
27132716
ret "Expected a type with " + uint::str(e_len) +

src/comp/syntax/ast.rs

-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ fn def_id_of_def(d: def) -> def_id {
8181
def_native_fn(id) { ret id; }
8282
def_upvar(id, _) { ret id; }
8383
}
84-
fail;
8584
}
8685

8786
// The set of meta_items that define the compilation environment of the crate,

src/comp/syntax/ext/base.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,12 @@ fn mk_ctxt(sess: &session) -> ext_ctxt {
5454
sess.span_err(sp, "unimplemented " + msg);
5555
fail;
5656
}
57-
let ext_span_unimpl = bind ext_span_unimpl_(sess, _, _);
57+
let ext_span_bug = bind ext_span_bug_(sess, _, _);
5858
fn ext_span_bug_(sess: &session, sp: span, msg: str) -> ! {
5959
sess.span_bug(sp, msg);
60-
fail;
6160
}
62-
let ext_span_bug = bind ext_span_bug_(sess, _, _);
63-
fn ext_bug_(sess: &session, msg: str) -> ! { sess.bug(msg); fail; }
61+
let ext_span_unimpl = bind ext_span_unimpl_(sess, _, _);
62+
fn ext_bug_(sess: &session, msg: str) -> ! { sess.bug(msg); }
6463
let ext_bug = bind ext_bug_(sess, _);
6564

6665

src/comp/syntax/ext/simplext.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ fn p_t_s_rec(cx: &ext_ctxt, m: &matchable, s: &selector, b: &binders) {
452452
match_expr(e) {
453453
if e == pat { some(leaf(match_exact)) } else { none }
454454
}
455-
_ { cx.bug("broken traversal in p_t_s_r"); fail }
455+
_ { cx.bug("broken traversal in p_t_s_r") }
456456
}
457457
}
458458
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) {
488488
fn select(cx: &ext_ctxt, m: &matchable) -> match_result {
489489
ret alt m {
490490
match_expr(e) { some(leaf(specialize_match(m))) }
491-
_ { cx.bug("broken traversal in p_t_s_r"); fail }
491+
_ { cx.bug("broken traversal in p_t_s_r") }
492492
}
493493
}
494494
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) {
517517
match_expr(e) {
518518
alt e.node { expr_mac(mac) { fn_m(mac) } _ { none } }
519519
}
520-
_ { cx.bug("broken traversal in p_t_s_r"); fail }
520+
_ { cx.bug("broken traversal in p_t_s_r") }
521521
}
522522
}
523523
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,
593593
_ { none }
594594
}
595595
}
596-
_ { cx.bug("broken traversal in p_t_s_r"); fail }
596+
_ { cx.bug("broken traversal in p_t_s_r") }
597597
}
598598
}
599599
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,
633633
_ { none }
634634
}
635635
}
636-
_ { cx.bug("broken traversal in p_t_s_r"); fail }
636+
_ { cx.bug("broken traversal in p_t_s_r") }
637637
}
638638
}
639639
p_t_s_rec(cx, match_expr(elts.(idx)),

src/comp/syntax/parse/lexer.rs

-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ fn next_token_inner(rdr: &reader) -> token::token {
541541
'%' { ret binop(rdr, token::PERCENT); }
542542
c { rdr.err(#fmt("unkown start of token: %d", c as int)); fail; }
543543
}
544-
fail;
545544
}
546545

547546
tag cmnt_style {

src/comp/syntax/parse/parser.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ fn spanned[T](lo: uint, hi: uint, node: &T) -> spanned[T] {
211211
fn parse_ident(p: &parser) -> ast::ident {
212212
alt p.peek() {
213213
token::IDENT(i, _) { p.bump(); ret p.get_str(i); }
214-
_ { p.fatal("expecting ident"); fail; }
214+
_ { p.fatal("expecting ident"); }
215215
}
216216
}
217217

@@ -331,7 +331,6 @@ fn parse_ty_obj(p: &parser, hi: &mutable uint) -> ast::ty_ {
331331
constrs: constrs});
332332
}
333333
}
334-
fail;
335334
}
336335
let meths =
337336
parse_seq(token::LBRACE, token::RBRACE, none, parse_method_sig, p);
@@ -589,7 +588,7 @@ fn parse_ty(p: &parser) -> @ast::ty {
589588
let path = parse_path(p);
590589
t = ast::ty_path(path, p.get_id());
591590
hi = path.span.hi;
592-
} else { p.fatal("expecting type"); t = ast::ty_nil; fail; }
591+
} else { p.fatal("expecting type"); }
593592
ret parse_ty_postfix(t, p);
594593
}
595594

@@ -1570,10 +1569,9 @@ fn parse_source_stmt(p: &parser) -> @ast::stmt {
15701569
let e = parse_expr(p);
15711570
ret @spanned(lo, e.span.hi, ast::stmt_expr(e, p.get_id()));
15721571
}
1572+
_ { p.fatal("expected statement"); }
15731573
}
15741574
}
1575-
p.fatal("expected statement");
1576-
fail;
15771575
}
15781576

15791577
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 {
16691667
p.fatal("expected ';' or '}' after " +
16701668
"expression but found " +
16711669
token::to_str(p.get_reader(), t));
1672-
fail;
16731670
}
16741671
stmts += ~[stmt];
16751672
}
@@ -1933,7 +1930,7 @@ fn parse_native_item(p: &parser, attrs: &ast::attribute[]) ->
19331930
ret parse_item_native_type(p, attrs);
19341931
} else if (eat_word(p, "fn")) {
19351932
ret parse_item_native_fn(p, attrs);
1936-
} else { unexpected(p, p.peek()); fail; }
1933+
} else { unexpected(p, p.peek()); }
19371934
}
19381935

19391936
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 {
19711968
abi = ast::native_abi_rust_intrinsic;
19721969
} else if (str::eq(t, "x86stdcall")) {
19731970
abi = ast::native_abi_x86stdcall;
1974-
} else { p.fatal("unsupported abi: " + t); fail; }
1971+
} else { p.fatal("unsupported abi: " + t); }
19751972
}
19761973
expect_word(p, "mod");
19771974
let id = parse_ident(p);
@@ -2071,7 +2068,6 @@ fn parse_auth(p: &parser) -> ast::_auth {
20712068
if eat_word(p, "unsafe") {
20722069
ret ast::auth_unsafe;
20732070
} else { unexpected(p, p.peek()); }
2074-
fail;
20752071
}
20762072

20772073
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) ->
22602256
}
22612257
_ { p.fatal("expecting an identifier"); }
22622258
}
2263-
fail;
22642259
}
22652260

22662261
fn parse_import(p: &parser) -> ast::view_item_ {
@@ -2277,7 +2272,6 @@ fn parse_import(p: &parser) -> ast::view_item_ {
22772272
}
22782273
_ { p.fatal("expecting an identifier"); }
22792274
}
2280-
fail;
22812275
}
22822276

22832277
fn parse_export(p: &parser) -> ast::view_item_ {
@@ -2307,7 +2301,6 @@ fn is_view_item(p: &parser) -> bool {
23072301
}
23082302
_ { ret false; }
23092303
}
2310-
ret false;
23112304
}
23122305

23132306
fn parse_view(p: &parser) -> (@ast::view_item)[] {

0 commit comments

Comments
 (0)