about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-11-02 18:45:43 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-11-03 08:31:47 -0800
commit02300dc90d4199724f46f6246b57cb10a1288910 (patch)
tree26b0e2a3a51e9f96e9fb3d128ec80f5ddb7ef168
parent2f08d263bab7816f13743fb7ed75b971890645a8 (diff)
parent76cc107811e28360c947a94a6037e354d7e901fc (diff)
downloadrust-02300dc90d4199724f46f6246b57cb10a1288910.tar.gz
rust-02300dc90d4199724f46f6246b57cb10a1288910.zip
rollup merge of #18545 : luqmana/fix-18539
-rw-r--r--src/librustc/middle/trans/closure.rs2
-rw-r--r--src/test/run-pass/issue-18539.rs23
2 files changed, 24 insertions, 1 deletions
diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs
index 44613e85a82..decd238627c 100644
--- a/src/librustc/middle/trans/closure.rs
+++ b/src/librustc/middle/trans/closure.rs
@@ -623,7 +623,7 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
     let retval = Call(bcx, fn_ptr, llargs.as_slice(), None);
     match f.sig.output {
         ty::FnConverging(output_type) => {
-            if type_is_zero_size(ccx, output_type) || fcx.llretslotptr.get().is_some() {
+            if return_type_is_void(ccx, output_type) || fcx.llretslotptr.get().is_some() {
                 RetVoid(bcx);
             } else {
                 Ret(bcx, retval);
diff --git a/src/test/run-pass/issue-18539.rs b/src/test/run-pass/issue-18539.rs
new file mode 100644
index 00000000000..90e20e30d10
--- /dev/null
+++ b/src/test/run-pass/issue-18539.rs
@@ -0,0 +1,23 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that coercing bare fn's that return a zero sized type to
+// a closure doesn't cause an LLVM ERROR
+
+struct Foo;
+
+fn uint_to_foo(_: uint) -> Foo {
+    Foo
+}
+
+#[allow(unused_must_use)]
+fn main() {
+    range(0u, 10).map(uint_to_foo);
+}