Skip to content

Commit ce3cecf

Browse files
committed
Use layout_of to detect C enums
1 parent 8760a5e commit ce3cecf

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/librustc_trans/abi.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use cabi_asmjs;
2626
use machine::{llalign_of_min, llsize_of, llsize_of_real, llsize_of_store};
2727
use type_::Type;
2828
use type_of;
29-
use adt;
3029

3130
use rustc::hir;
3231
use rustc::ty::{self, Ty};
@@ -36,6 +35,7 @@ use std::cmp;
3635

3736
pub use syntax::abi::Abi;
3837
pub use rustc::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
38+
use rustc::ty::layout::Layout;
3939

4040
#[derive(Clone, Copy, PartialEq, Debug)]
4141
enum ArgKind {
@@ -318,13 +318,10 @@ impl FnType {
318318
if ty.is_integral() {
319319
arg.signedness = Some(ty.is_signed());
320320
}
321-
// Rust enum types that map onto C enums (LLVM integers) also
322-
// need to follow the target ABI zero-/sign-extension rules.
323-
if let ty::TyEnum(..) = ty.sty {
324-
if arg.ty.kind() == llvm::Integer {
325-
let repr = adt::represent_type(ccx, ty);
326-
arg.signedness = Some(adt::is_discr_signed(&repr));
327-
}
321+
// Rust enum types that map onto C enums also need to follow
322+
// the target ABI zero-/sign-extension rules.
323+
if let Layout::CEnum { signed, .. } = *ccx.layout_of(ty) {
324+
arg.signedness = Some(signed);
328325
}
329326
if llsize_of_real(ccx, arg.ty) == 0 {
330327
// For some forsaken reason, x86_64-pc-windows-gnu

0 commit comments

Comments
 (0)