]> git.lizzy.rs Git - rust.git/commitdiff
In trans, allow _|_-typed things to be the argument to fail
authorTim Chevalier <chevalier@alum.wellesley.edu>
Thu, 19 Jan 2012 21:29:26 +0000 (13:29 -0800)
committerTim Chevalier <chevalier@alum.wellesley.edu>
Thu, 19 Jan 2012 21:30:31 +0000 (13:30 -0800)
Rationale: _|_-typed things diverge, so it's safe to use them in
any context.

Closes #1465

src/comp/middle/trans.rs
src/test/run-fail/do-while-fail.rs [new file with mode: 0644]

index c519461887dc7f1ea026baccd241ebf451c49122..92a37ab36d912c76a02375ed46eb6256555ba22f 100644 (file)
@@ -3775,7 +3775,7 @@ fn trans_fail_expr(bcx: @block_ctxt, sp_opt: option::t<span>,
                 bcx, expr_res.val, type_of_or_i8(
                     bcx, ty::mk_mach_uint(tcx, ast::ty_u8)));
             ret trans_fail_value(bcx, sp_opt, data);
-        } else if bcx.unreachable {
+        } else if bcx.unreachable || ty::type_is_bot(tcx, e_ty) {
             ret bcx;
         } else {
             bcx_ccx(bcx).sess.span_bug(
diff --git a/src/test/run-fail/do-while-fail.rs b/src/test/run-fail/do-while-fail.rs
new file mode 100644 (file)
index 0000000..38c6d38
--- /dev/null
@@ -0,0 +1,4 @@
+// error-pattern:giraffe
+fn main() {
+  fail do { fail "giraffe" } while true;
+}