diff options
-rw-r--r-- | libbindgen/src/clang.rs | 7 | ||||
-rw-r--r-- | libbindgen/src/ir/enum_ty.rs | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/libbindgen/src/clang.rs b/libbindgen/src/clang.rs index 6c95b22f..08c77b19 100644 --- a/libbindgen/src/clang.rs +++ b/libbindgen/src/clang.rs @@ -362,11 +362,12 @@ impl Cursor { /// Get the integer representation type used to hold this cursor's referent /// enum type. - pub fn enum_type(&self) -> Type { + pub fn enum_type(&self) -> Option<Type> { unsafe { - Type { + let t = Type { x: clang_getEnumDeclIntegerType(self.x), - } + }; + if t.kind() == CXType_Invalid { None } else { Some(t) } } } diff --git a/libbindgen/src/ir/enum_ty.rs b/libbindgen/src/ir/enum_ty.rs index 6085833d..0d4f955b 100644 --- a/libbindgen/src/ir/enum_ty.rs +++ b/libbindgen/src/ir/enum_ty.rs @@ -49,8 +49,8 @@ impl Enum { } let declaration = ty.declaration().canonical(); - let repr = Item::from_ty(&declaration.enum_type(), None, None, ctx) - .ok(); + let et = &declaration.enum_type().expect("This should be an enum since we checked above!"); + let repr = Item::from_ty(et, None, None, ctx).ok(); let mut variants = vec![]; let is_signed = match repr { |