Skip to content

Cleanup #280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions doc/rust.texi
Original file line number Diff line number Diff line change
Expand Up @@ -3310,11 +3310,14 @@ for each (str s in _str.split(txt, "\n")) @{

An @code{if} statement is a conditional branch in program control. The form of
an @code{if} statement is a parenthesized condition expression, followed by a
consequent block, and an optional trailing @code{else} block. The condition
expression must have type @code{bool}. If the condition expression evaluates
to @code{true}, the consequent block is executed and any @code{else} block is
skipped. If the condition expression evaluates to @code{false}, the consequent
block is skipped and any @code{else} block is executed.
consequent block, any number of @code{else if} conditions and blocks, and an
optional trailing @code{else} block. The condition expressions must have type
@code{bool}. If a condition expression evaluates to @code{true}, the
consequent block is executed and any subsequent @code{else if} or @code{else}
block is skipped. If a condition expression evaluates to @code{false}, the
consequent block is skipped and any subsequent @code{else if} condition is
evaluated. If all @code{if} and @code{else if} conditions evaluate to @code{false}
then any @code{else} block is executed.

@node Ref.Stmt.Alt
@subsection Ref.Stmt.Alt
Expand Down
3 changes: 0 additions & 3 deletions src/comp/middle/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,6 @@ fn variant_types(@crate_ctxt cx, &ast.variant v) -> vec[@ty.t] {
}
}
case (ty.ty_tag(_, _)) { /* nothing */ }
case (_) { fail; }
}
ret tys;
}
Expand Down Expand Up @@ -1966,7 +1965,6 @@ fn iter_structural_ty_full(@block_ctxt cx,
j += 1;
}
}
case (_) { fail; }
}

variant_cx.build.Br(next_cx.llbb);
Expand Down Expand Up @@ -2133,7 +2131,6 @@ fn iter_sequence(@block_ctxt cx,
auto et = plain_ty(ty.ty_machine(common.ty_u8));
ret iter_sequence_body(cx, v, et, f, true);
}
case (_) { fail; }
}
cx.fcx.ccx.sess.bug("bad type in trans.iter_sequence");
fail;
Expand Down
6 changes: 0 additions & 6 deletions src/comp/middle/typeck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1861,9 +1861,6 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
case (ty.ty_chan(?it)) {
item_t = it;
}
case (_) {
fail;
}
}
auto rhs_1 = demand_expr(fcx, item_t, rhs_0);

Expand All @@ -1884,9 +1881,6 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
case (ty.ty_port(?it)) {
item_t = it;
}
case (_) {
fail;
}
}
auto lhs_1 = demand_expr(fcx, item_t, lhs_0);

Expand Down
1 change: 0 additions & 1 deletion src/lib/deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ fn create[T]() -> t[T] {
fn get[T](vec[cell[T]] elts, uint i) -> T {
alt (elts.(i)) {
case (option.some[T](?t)) { ret t; }
case (_) { fail; }
}
fail; // FIXME: remove me when exhaustiveness checking works
}
Expand Down
1 change: 0 additions & 1 deletion src/lib/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
fn get(&K key) -> V {
alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) {
case (option.some[V](?val)) { ret val; }
case (_) { fail; }
}
fail; // FIXME: remove me when exhaustiveness checking works
}
Expand Down
25 changes: 24 additions & 1 deletion src/test/run-pass/else-if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,27 @@ fn main() {
check(true);
}

}
if (1 == 2) {
check(false);
} else if (2 == 2) {
if (1 == 1) {
check(true);
} else {
if (2 == 1) {
check(false);
} else {
check(false);
}
}
}

if (1 == 2) {
check(false);
} else {
if (1 == 2) {
check(false);
} else {
check(true);
}
}
}