diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-01-29 15:13:53 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-01-29 15:13:53 +0100 |
commit | 450970dcc1a710b94d34242b85038a39a8c71fd2 (patch) | |
tree | c07a9dbac7c0bd787122a6cd517acf88b29e1d76 /src/codegen/mod.rs | |
parent | 8725aea78fb312d678fc17088eb8ba5c883c720c (diff) |
codegen: Make the cyclic typedef name detection catch more cases.
By looking through typedefs, we also catch more complex cases like the ones that
appear on Android's stdlib.
Fixes #946
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r-- | src/codegen/mod.rs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index af202a02..0ad4e805 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -614,14 +614,20 @@ impl CodeGenerator for Type { .resolve(ctx); let name = item.canonical_name(ctx); - // Try to catch the common pattern: - // - // typedef struct foo { ... } foo; - // - // here. - // - if inner_item.canonical_name(ctx) == name { - return; + { + let through_type_aliases = inner.into_resolver() + .through_type_refs() + .through_type_aliases() + .resolve(ctx); + + // Try to catch the common pattern: + // + // typedef struct foo { ... } foo; + // + // here, and also other more complex cases like #946. + if through_type_aliases.canonical_name(ctx) == name { + return; + } } // If this is a known named type, disallow generating anything |