Skip to content

Commit 02300dc

Browse files
committed
rollup merge of #18545 : luqmana/fix-18539
2 parents 2f08d26 + 76cc107 commit 02300dc

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/librustc/middle/trans/closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
623623
let retval = Call(bcx, fn_ptr, llargs.as_slice(), None);
624624
match f.sig.output {
625625
ty::FnConverging(output_type) => {
626-
if type_is_zero_size(ccx, output_type) || fcx.llretslotptr.get().is_some() {
626+
if return_type_is_void(ccx, output_type) || fcx.llretslotptr.get().is_some() {
627627
RetVoid(bcx);
628628
} else {
629629
Ret(bcx, retval);

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

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
// Test that coercing bare fn's that return a zero sized type to
12+
// a closure doesn't cause an LLVM ERROR
13+
14+
struct Foo;
15+
16+
fn uint_to_foo(_: uint) -> Foo {
17+
Foo
18+
}
19+
20+
#[allow(unused_must_use)]
21+
fn main() {
22+
range(0u, 10).map(uint_to_foo);
23+
}

0 commit comments

Comments
 (0)