summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ir/context.rs4
-rw-r--r--src/ir/item.rs9
-rw-r--r--src/ir/ty.rs14
3 files changed, 16 insertions, 11 deletions
diff --git a/src/ir/context.rs b/src/ir/context.rs
index c95d5179..fa001ba6 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -424,7 +424,9 @@ impl<'ctx> BindgenContext<'ctx> {
for (id, ty, loc, parent_id) in typerefs {
let _resolved = {
let resolved = Item::from_ty(&ty, loc, parent_id, self)
- .expect("What happened?");
+ .unwrap_or_else(|_| {
+ Item::new_opaque_type(self.next_item_id(), &ty, self)
+ });
let mut item = self.items.get_mut(&id).unwrap();
*item.kind_mut().as_type_mut().unwrap().kind_mut() =
diff --git a/src/ir/item.rs b/src/ir/item.rs
index 89422e87..5477dee9 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -433,10 +433,11 @@ impl Item {
}
}
- fn new_opaque_type(with_id: ItemId,
- ty: &clang::Type,
- ctx: &mut BindgenContext)
- -> ItemId {
+ /// Construct a new opaque item type.
+ pub fn new_opaque_type(with_id: ItemId,
+ ty: &clang::Type,
+ ctx: &mut BindgenContext)
+ -> ItemId {
let ty = Opaque::from_clang_ty(ty);
let kind = ItemKind::Type(ty);
let parent = ctx.root_module();
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index 60d750ed..a28727c9 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -1093,12 +1093,14 @@ impl Type {
name = location.spelling();
}
- let complex = CompInfo::from_ty(potential_id,
- ty,
- Some(location),
- ctx)
- .expect("C'mon");
- TypeKind::Comp(complex)
+ if let Ok(complex) = CompInfo::from_ty(potential_id,
+ ty,
+ Some(location),
+ ctx) {
+ TypeKind::Comp(complex)
+ } else {
+ return Ok(ParseResult::New(Opaque::from_clang_ty(ty), None));
+ }
}
CXCursor_TypeAliasTemplateDecl => {
debug!("TypeAliasTemplateDecl");