diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-11-07 19:24:25 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-07 19:24:25 -0500 |
commit | fbc55435c58255a290a413eebeaa359a48ec20c6 (patch) | |
tree | 9cdcce979a6709d3874a4a266c834f065bcd3f5f | |
parent | 1a2e2b365f1a5cb4982cbcde6b92742f6bccaa3b (diff) | |
parent | 1088671defd177ce0659ef96f1cf9dcd352d0c69 (diff) |
Auto merge of #1436 - sanxiyn:canonical-path, r=emilio
Use canonical path for type alias loop detection
Fix #1435
-rw-r--r-- | src/codegen/mod.rs | 3 | ||||
-rw-r--r-- | tests/expectations/tests/issue-1435.rs | 26 | ||||
-rw-r--r-- | tests/headers/issue-1435.hpp | 7 |
3 files changed, 35 insertions, 1 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 983ee4dd..34b5b4d9 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -666,6 +666,7 @@ impl CodeGenerator for Type { .through_type_refs() .resolve(ctx); let name = item.canonical_name(ctx); + let path = item.canonical_path(ctx); { let through_type_aliases = inner.into_resolver() @@ -678,7 +679,7 @@ impl CodeGenerator for Type { // typedef struct foo { ... } foo; // // here, and also other more complex cases like #946. - if through_type_aliases.canonical_name(ctx) == name { + if through_type_aliases.canonical_path(ctx) == path { return; } } diff --git a/tests/expectations/tests/issue-1435.rs b/tests/expectations/tests/issue-1435.rs new file mode 100644 index 00000000..4c8b52e6 --- /dev/null +++ b/tests/expectations/tests/issue-1435.rs @@ -0,0 +1,26 @@ +/* automatically generated by rust-bindgen */ + +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::root; + pub mod ns { + #[allow(unused_imports)] + use self::super::super::root; + pub const AB_A: root::ns::AB = 0; + pub const AB_B: root::ns::AB = 1; + pub type AB = i32; + } + pub use self::super::root::ns::AB; + extern "C" { + #[link_name = "\u{1}_ZL2kA"] + pub static kA: root::AB; + } +} diff --git a/tests/headers/issue-1435.hpp b/tests/headers/issue-1435.hpp new file mode 100644 index 00000000..fbf3c507 --- /dev/null +++ b/tests/headers/issue-1435.hpp @@ -0,0 +1,7 @@ +// bindgen-flags: --enable-cxx-namespaces + +namespace ns { +enum class AB { A, B }; +} +using AB = ns::AB; +static const AB kA = AB::A; |