Skip to content

Commit 0136bc2

Browse files
committed
---
yaml --- r: 2811 b: refs/heads/master c: 1a96e79 h: refs/heads/master i: 2809: ccabf76 2807: 90a3b4e v: v3
1 parent 0f20858 commit 0136bc2

File tree

6 files changed

+55
-13
lines changed

6 files changed

+55
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: af6b4821c163e5ad22868a270541dc0b7a04534f
2+
refs/heads/master: 1a96e79fe0a0d30bddd2cda1793cfa5907fa6c1d

trunk/src/comp/middle/ty.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,6 +2209,12 @@ mod unify {
22092209
if (eq_ty(expected, actual)) { ret ures_ok(expected); }
22102210

22112211
alt (struct(cx.tcx, actual)) {
2212+
2213+
// a _|_ type can be used anywhere
2214+
case (ty::ty_bot) {
2215+
ret ures_ok(expected);
2216+
}
2217+
22122218
// If the RHS is a variable type, then just do the appropriate
22132219
// binding.
22142220
case (ty::ty_var(?actual_id)) {

trunk/src/comp/middle/typeck.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,17 +1341,13 @@ mod pushdown {
13411341
ann_to_type(scx.fcx.ccx.tcx.node_types, ann), adk);
13421342

13431343
auto then_t = ty::block_ty(scx.fcx.ccx.tcx, then_0);
1344-
if (!ty::type_is_bot(scx.fcx.ccx.tcx, then_t)) {
1345-
pushdown_block(scx, expected, then_0);
1346-
}
1344+
pushdown_block(scx, expected, then_0);
13471345

13481346
alt (else_0) {
13491347
case (none[@ast::expr]) { /* no-op */ }
13501348
case (some[@ast::expr](?e_0)) {
13511349
auto else_t = ty::expr_ty(scx.fcx.ccx.tcx, e_0);
1352-
if (!ty::type_is_bot(scx.fcx.ccx.tcx, else_t)) {
1353-
pushdown_expr(scx, expected, e_0);
1354-
}
1350+
pushdown_expr(scx, expected, e_0);
13551351
}
13561352
}
13571353
write::ty_only_fixup(scx, ann.id, t);
@@ -1472,10 +1468,7 @@ mod pushdown {
14721468
for (ast::arm arm_0 in arms_0) {
14731469
pushdown_block(scx, expected, arm_0.block);
14741470
auto bty = block_ty(scx.fcx.ccx.tcx, arm_0.block);
1475-
// Failing alt arms don't need to have a matching type
1476-
if (!ty::type_is_bot(scx.fcx.ccx.tcx, bty)) {
1477-
t = demand::simple(scx, e.span, t, bty);
1478-
}
1471+
t = demand::simple(scx, e.span, t, bty);
14791472
}
14801473
write::ty_only_fixup(scx, ann.id, t);
14811474
}
@@ -2245,8 +2238,6 @@ fn check_expr(&@stmt_ctxt scx, &@ast::expr expr) {
22452238

22462239
pushdown::pushdown_expr(scx, pattern_ty, expr);
22472240

2248-
// FIXME: If all the the arms were ty_bot then the result should
2249-
// also be ty_bot. At the moment this doesn't seem to matter
22502241
write::ty_only_fixup(scx, a.id, result_ty);
22512242
}
22522243

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// xfail-stage0
2+
// xfail-stage1
3+
// xfail-stage2
4+
// xfail-stage3
5+
use std;
6+
import std::option::*;
7+
8+
fn foo(str s) {
9+
}
10+
11+
fn main() {
12+
auto i = alt (some[int](3)) {
13+
case (none[int]) {
14+
fail
15+
}
16+
case (some[int](_)) {
17+
fail
18+
}
19+
};
20+
foo(i);
21+
}

trunk/src/test/run-pass/alt-bot.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// xfail-stage0
2+
use std;
3+
import std::option::*;
4+
5+
fn main() {
6+
let int i = alt (some[int](3)) {
7+
case (none[int]) {
8+
fail
9+
}
10+
case (some[int](_)) {
11+
5
12+
}
13+
};
14+
log i;
15+
}

trunk/src/test/run-pass/if-bot.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fn main() {
2+
let int i = if (false) {
3+
fail
4+
}
5+
else {
6+
5
7+
};
8+
log i;
9+
}

0 commit comments

Comments
 (0)