diff options
author | Tai Sassen-Liang <tsl@rupsvak.net> | 2016-11-22 23:58:48 +0100 |
---|---|---|
committer | Tai Sassen-Liang <tsl@rupsvak.net> | 2016-11-22 23:58:48 +0100 |
commit | b8b3d781cd05c56e7748230b2468524098dc1b65 (patch) | |
tree | 355ffc24b4d6a184865169a8b49d9b891beb55c7 | |
parent | 85a9dd3bb491b785318f76c0e176149b5b02934d (diff) |
Circuit-break if Cursor::enum_type returns None
As discussed with @emilio. Part of #125.
-rw-r--r-- | libbindgen/src/ir/enum_ty.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libbindgen/src/ir/enum_ty.rs b/libbindgen/src/ir/enum_ty.rs index 33a4fcfa..14ca4965 100644 --- a/libbindgen/src/ir/enum_ty.rs +++ b/libbindgen/src/ir/enum_ty.rs @@ -49,8 +49,11 @@ impl Enum { } let declaration = ty.declaration().canonical(); - let et = &declaration.enum_type().expect("Expected an enum type"); - let repr = Item::from_ty(et, None, None, ctx).ok(); + let et = declaration.enum_type(); + if et.is_none() { + return Err(ParseError::Continue); + } + let repr = Item::from_ty(&et.unwrap(), None, None, ctx).ok(); let mut variants = vec![]; let is_signed = match repr { |