diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-02-07 13:35:34 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-02-10 14:03:04 +0100 |
commit | 7e1b7d98d1da5a449ae18f6f60bac29b9079b9ab (patch) | |
tree | c210115eb181cbf45adc553f8aaaec557644db65 /src | |
parent | 0ae42f2c55305aab12b2f55346001b7d5539cb6f (diff) |
ir: Don't parse non-semantic-children cursor as inner structs.
Fixes: https://github.com/servo/rust-bindgen/issues/482
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() && |