about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2016-09-07 21:03:21 +0200
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2016-09-07 21:03:21 +0200
commitce3cecf116a2d691c53f37c1d257a416ecfd381b (patch)
tree3e5a2e0cbf5c3887127747653dbef692c0902bea /src
parent8760a5e3cc8bab89053ef9cee9757160e76f517d (diff)
downloadrust-ce3cecf116a2d691c53f37c1d257a416ecfd381b.tar.gz
rust-ce3cecf116a2d691c53f37c1d257a416ecfd381b.zip
Use layout_of to detect C enums
Diffstat (limited to 'src')
-rw-r--r--src/librustc_trans/abi.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/librustc_trans/abi.rs b/src/librustc_trans/abi.rs
index ab0fd0c92ed..42289ec094f 100644
--- a/src/librustc_trans/abi.rs
+++ b/src/librustc_trans/abi.rs
@@ -26,7 +26,6 @@ use cabi_asmjs;
 use machine::{llalign_of_min, llsize_of, llsize_of_real, llsize_of_store};
 use type_::Type;
 use type_of;
-use adt;
 
 use rustc::hir;
 use rustc::ty::{self, Ty};
@@ -36,6 +35,7 @@ use std::cmp;
 
 pub use syntax::abi::Abi;
 pub use rustc::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
+use rustc::ty::layout::Layout;
 
 #[derive(Clone, Copy, PartialEq, Debug)]
 enum ArgKind {
@@ -318,13 +318,10 @@ impl FnType {
                 if ty.is_integral() {
                     arg.signedness = Some(ty.is_signed());
                 }
-                // Rust enum types that map onto C enums (LLVM integers) also
-                // need to follow the target ABI zero-/sign-extension rules.
-                if let ty::TyEnum(..) = ty.sty {
-                    if arg.ty.kind() == llvm::Integer {
-                        let repr = adt::represent_type(ccx, ty);
-                        arg.signedness = Some(adt::is_discr_signed(&repr));
-                    }
+                // Rust enum types that map onto C enums also need to follow
+                // the target ABI zero-/sign-extension rules.
+                if let Layout::CEnum { signed, .. } = *ccx.layout_of(ty) {
+                    arg.signedness = Some(signed);
                 }
                 if llsize_of_real(ccx, arg.ty) == 0 {
                     // For some forsaken reason, x86_64-pc-windows-gnu