Skip to content

Commit 6b6036c

Browse files
Mark-Simulacrumnikomatsakis
authored andcommitted
Fix ICE on i686 when calling immediate() on OperandValue::Ref in return
1 parent 8b7e7b8 commit 6b6036c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/librustc_trans/mir/block.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,11 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
222222
load
223223
} else {
224224
let op = self.trans_consume(&bcx, &mir::Lvalue::Local(mir::RETURN_POINTER));
225-
op.pack_if_pair(&bcx).immediate()
225+
if let Ref(llval) = op.val {
226+
base::load_ty(&bcx, llval, op.ty)
227+
} else {
228+
op.pack_if_pair(&bcx).immediate()
229+
}
226230
};
227231
bcx.ret(llval);
228232
}

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2017 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+
#[repr(u64)]
12+
enum A {
13+
A = 0u64,
14+
B = !0u64,
15+
}
16+
17+
fn cmp() -> A {
18+
A::B
19+
}
20+
21+
fn main() {}

0 commit comments

Comments
 (0)