diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/codegen/mod.rs | 2 | ||||
-rw-r--r-- | src/ir/comp.rs | 15 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 7469abb9..99400f7a 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -2190,7 +2190,7 @@ impl ToRustTy for Type { .map(|arg| arg.to_rust_ty(ctx)) .collect::<Vec<_>>(); - path.segments.last_mut().unwrap().parameters = if + path.segments.last_mut().unwrap().parameters = if template_args.is_empty() { None } else { diff --git a/src/ir/comp.rs b/src/ir/comp.rs index b02cd342..7c58e233 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -669,11 +669,20 @@ impl CompInfo { CXCursor_UnionDecl | CXCursor_ClassTemplate | CXCursor_ClassDecl => { + // We can find non-semantic children here, clang uses a + // StructDecl to note incomplete structs that hasn't been + // forward-declared before, see: + // + // https://github.com/servo/rust-bindgen/issues/482 + if cur.semantic_parent() != cursor { + return CXChildVisit_Continue; + } + let inner = Item::parse(cur, Some(potential_id), ctx) .expect("Inner ClassDecl"); - if !ci.inner_types.contains(&inner) { - ci.inner_types.push(inner); - } + + ci.inner_types.push(inner); + // A declaration of an union or a struct without name could // also be an unnamed field, unfortunately. if cur.spelling().is_empty() && |