Skip to content

Commit 97c008c

Browse files
Fix ICE on i686 when calling immediate() on OperandValue::Ref in return
1 parent 74e5b7d commit 97c008c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/librustc_trans/mir/block.rs

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

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

+21
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)