Skip to content

Commit 1088671

Browse files
committed
Use canonical path for type alias loop detection
1 parent 1a2e2b3 commit 1088671

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

src/codegen/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ impl CodeGenerator for Type {
666666
.through_type_refs()
667667
.resolve(ctx);
668668
let name = item.canonical_name(ctx);
669+
let path = item.canonical_path(ctx);
669670

670671
{
671672
let through_type_aliases = inner.into_resolver()
@@ -678,7 +679,7 @@ impl CodeGenerator for Type {
678679
// typedef struct foo { ... } foo;
679680
//
680681
// here, and also other more complex cases like #946.
681-
if through_type_aliases.canonical_name(ctx) == name {
682+
if through_type_aliases.canonical_path(ctx) == path {
682683
return;
683684
}
684685
}
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
#![allow(
4+
dead_code,
5+
non_snake_case,
6+
non_camel_case_types,
7+
non_upper_case_globals
8+
)]
9+
10+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
11+
pub mod root {
12+
#[allow(unused_imports)]
13+
use self::super::root;
14+
pub mod ns {
15+
#[allow(unused_imports)]
16+
use self::super::super::root;
17+
pub const AB_A: root::ns::AB = 0;
18+
pub const AB_B: root::ns::AB = 1;
19+
pub type AB = i32;
20+
}
21+
pub use self::super::root::ns::AB;
22+
extern "C" {
23+
#[link_name = "\u{1}_ZL2kA"]
24+
pub static kA: root::AB;
25+
}
26+
}

tests/headers/issue-1435.hpp

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// bindgen-flags: --enable-cxx-namespaces
2+
3+
namespace ns {
4+
enum class AB { A, B };
5+
}
6+
using AB = ns::AB;
7+
static const AB kA = AB::A;

0 commit comments

Comments
 (0)