summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <me@emiliocobos.me>2016-04-16 04:01:52 +0200
committerEmilio Cobos Álvarez <me@emiliocobos.me>2016-04-16 04:01:52 +0200
commit93c064bf63dab1adb645e1ca4788c015c9d31807 (patch)
treeb0b6b44c1820464612cf3b86a18bf8d491d4e843
parentd1790e7d91370a4d1a4088f168ecfb11adfb9556 (diff)
parser: Restructure anonymous struct generation to prevent some double borrows
-rw-r--r--src/parser.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/parser.rs b/src/parser.rs
index c1601a42..da093f84 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -595,7 +595,7 @@ fn visit_composite(cursor: &Cursor, parent: &Cursor,
_ => panic!("bitfield width not supported: {}", layout_size),
};
- // NB: We rely on the ULongLong not being translated
+ // NB: We rely on the ULongLong not being translated
// (using the common uintxx_t name)
let ti = TypeInfo::new(name.into(),
ctx.current_module_id,
@@ -647,8 +647,18 @@ fn visit_composite(cursor: &Cursor, parent: &Cursor,
if let Some(&mut CompMember::Field(ref mut info)) = ci.members.last_mut() {
if bitfields.is_none() && info.bitfields.is_none() {
- if info.ty.was_unnamed() && ty.was_unnamed() &&
- info.ty.name() == ty.name() {
+ let should_replace = if let TComp(ref ci) = info.ty {
+ if ci.borrow().was_unnamed && ty.was_unnamed() &&
+ Some(&ci.borrow().name) == ty.name().as_ref() {
+ true
+ } else {
+ false
+ }
+ } else {
+ false
+ };
+
+ if should_replace {
*info = FieldInfo::new(name, ty, comment, bitfields);
return CXChildVisit_Continue;
}