]> git.lizzy.rs Git - rust.git/commitdiff
Fix ICE on i686 when calling immediate() on OperandValue::Ref in return
authorMark Simulacrum <mark.simulacrum@gmail.com>
Thu, 5 Jan 2017 19:22:51 +0000 (12:22 -0700)
committerMark Simulacrum <mark.simulacrum@gmail.com>
Thu, 5 Jan 2017 19:59:50 +0000 (12:59 -0700)
src/librustc_trans/mir/block.rs
src/test/run-pass/issue-38727.rs [new file with mode: 0644]

index 6d92cd99fbeb971b3977ef32c9066027d648bb6e..7d4a1ab5ae70e1f7b991934c94d1e0dbf036f60a 100644 (file)
@@ -223,7 +223,11 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock,
                     load
                 } else {
                     let op = self.trans_consume(&bcx, &mir::Lvalue::Local(mir::RETURN_POINTER));
-                    op.pack_if_pair(&bcx).immediate()
+                    if let Ref(llval) = op.val {
+                        base::load_ty(&bcx, llval, op.ty)
+                    } else {
+                        op.pack_if_pair(&bcx).immediate()
+                    }
                 };
                 bcx.ret(llval);
             }
diff --git a/src/test/run-pass/issue-38727.rs b/src/test/run-pass/issue-38727.rs
new file mode 100644 (file)
index 0000000..e60b6a9
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2017 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.
+
+#[repr(u64)]
+enum A {
+    A = 0u64,
+    B = !0u64,
+}
+
+fn cmp() -> A {
+    A::B
+}
+
+fn main() {}