about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBjörn Steinbrink <bsteinbr@gmail.com>2015-06-10 00:07:47 +0200
committerBjörn Steinbrink <bsteinbr@gmail.com>2015-06-10 00:07:47 +0200
commit96bc00f30e66e6b48f3f9ad34344fe56dea812dc (patch)
tree22920555f6c0b43e308e79510c2d9387dffe242b
parent8a3f5af8c98e123247a2847c52474f42874d23fa (diff)
downloadrust-96bc00f30e66e6b48f3f9ad34344fe56dea812dc.tar.gz
rust-96bc00f30e66e6b48f3f9ad34344fe56dea812dc.zip
Use the correct type of undef value for ignored return values in trans_named_tuple_constructor
Fixes #26127
-rw-r--r--src/librustc_trans/trans/base.rs2
-rw-r--r--src/test/run-pass/issue26127.rs21
2 files changed, 22 insertions, 1 deletions
diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs
index 390c0b035fd..8eb655ccb7a 100644
--- a/src/librustc_trans/trans/base.rs
+++ b/src/librustc_trans/trans/base.rs
@@ -1676,7 +1676,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
             if !type_is_zero_size(ccx, result_ty) {
                 alloc_ty(bcx, result_ty, "constructor_result")
             } else {
-                C_undef(type_of::type_of(ccx, result_ty))
+                C_undef(type_of::type_of(ccx, result_ty).ptr_to())
             }
         }
     };
diff --git a/src/test/run-pass/issue26127.rs b/src/test/run-pass/issue26127.rs
new file mode 100644
index 00000000000..75cbcc83d61
--- /dev/null
+++ b/src/test/run-pass/issue26127.rs
@@ -0,0 +1,21 @@
+// Copyright 2015 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.
+
+trait Tr { type T; }
+impl Tr for u8 { type T=(); }
+struct S<I: Tr>(I::T);
+
+fn foo<I: Tr>(i: I::T) {
+    S::<I>(i);
+}
+
+fn main() {
+    foo::<u8>(());
+}