Skip to content

Commit bb57e41

Browse files
committed
auto merge of #14643 : jakub-/rust/infinite-loop-unreachable, r=alexcrichton
2 parents a7ac6a4 + b9752b6 commit bb57e41

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/librustc/middle/trans/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ pub fn trans_arg_datum<'a>(
802802
// "undef" value, as such a value should never
803803
// be inspected. It's important for the value
804804
// to have type lldestty (the callee's expected type).
805-
let llformal_arg_ty = type_of::type_of(ccx, formal_arg_ty);
805+
let llformal_arg_ty = type_of::type_of_explicit_arg(ccx, formal_arg_ty);
806806
unsafe {
807807
val = llvm::LLVMGetUndef(llformal_arg_ty.to_ref());
808808
}

src/librustc/middle/trans/controlflow.rs

+4
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ pub fn trans_loop<'a>(bcx:&'a Block<'a>,
264264

265265
fcx.pop_loop_cleanup_scope(loop_id);
266266

267+
if ty::type_is_bot(node_id_type(bcx, loop_id)) {
268+
Unreachable(next_bcx_in);
269+
}
270+
267271
return next_bcx_in;
268272
}
269273

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

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2014 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+
extern crate libc;
12+
13+
fn foo(_: proc()) {}
14+
15+
fn main() {
16+
foo(loop {
17+
unsafe { libc::exit(0 as libc::c_int); }
18+
});
19+
2u + (loop {});
20+
-(loop {});
21+
}

0 commit comments

Comments
 (0)