Skip to content

Commit 15e4438

Browse files
committed
auto merge of #6665 : catamorphism/rust/issue-5741, r=nikomatsakis
r? @nikomatsakis The way we deal with unreachable expressions in trans is pretty ad hoc, but this at least doesn't make it worse, and eliminates the LLVM assertion failure reported in #5741.
2 parents 799f281 + 8c68c4a commit 15e4438

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/librustc/middle/trans/expr.rs

+4
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block {
499499
let mut bcx = bcx;
500500
let _icx = bcx.insn_ctxt("trans_rvalue_stmt");
501501

502+
if bcx.unreachable {
503+
return bcx;
504+
}
505+
502506
trace_span!(bcx, expr.span, @shorten(bcx.expr_to_str(expr)));
503507

504508
match expr.node {

src/test/run-pass/issue-5741.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
return;
13+
while io::stdin().read_line() != ~"quit" { };
14+
}

0 commit comments

Comments
 (0)