summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2017-01-13 21:40:17 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-01-13 21:40:17 +0100
commit0ceeaf8d34b85da08a127db6668854b9ca5a1a54 (patch)
tree0ce0288298d131af2e24d39c1abffc8de86d9fe7
parentdfb25b389bec5492b6fd61e92a2552cab03a6afc (diff)
codegen: Fix use generation for non-root module.
-rw-r--r--bindgen-integration/cpp/Test.h2
-rw-r--r--libbindgen/src/codegen/mod.rs8
-rw-r--r--libbindgen/tests/expectations/tests/anon_enum.rs2
-rw-r--r--libbindgen/tests/expectations/tests/bitfield_method_mangling.rs2
-rw-r--r--libbindgen/tests/expectations/tests/inherit_typedef.rs2
-rw-r--r--libbindgen/tests/expectations/tests/union_fields.rs2
-rw-r--r--libbindgen/tests/expectations/tests/unknown_attr.rs2
7 files changed, 14 insertions, 6 deletions
diff --git a/bindgen-integration/cpp/Test.h b/bindgen-integration/cpp/Test.h
index 21f6d1a7..ebd58649 100644
--- a/bindgen-integration/cpp/Test.h
+++ b/bindgen-integration/cpp/Test.h
@@ -8,3 +8,5 @@ public:
Test(int foo);
Test(double foo);
};
+
+typedef Test TypeAlias;
diff --git a/libbindgen/src/codegen/mod.rs b/libbindgen/src/codegen/mod.rs
index b4388020..932e2b75 100644
--- a/libbindgen/src/codegen/mod.rs
+++ b/libbindgen/src/codegen/mod.rs
@@ -538,7 +538,13 @@ impl CodeGenerator for Type {
_ => None,
};
- let typedef = if let Some(p) = simple_enum_path {
+ let typedef = if let Some(mut p) = simple_enum_path {
+ if p.segments.len() == 1 {
+ p.segments.insert(0, ast::PathSegment {
+ identifier: ctx.ext_cx().ident_of("self"),
+ parameters: None,
+ });
+ }
typedef.use_().build(p).as_(rust_name)
} else {
let mut generics = typedef.type_(rust_name).generics();
diff --git a/libbindgen/tests/expectations/tests/anon_enum.rs b/libbindgen/tests/expectations/tests/anon_enum.rs
index 8a287d3d..3b05eab8 100644
--- a/libbindgen/tests/expectations/tests/anon_enum.rs
+++ b/libbindgen/tests/expectations/tests/anon_enum.rs
@@ -27,4 +27,4 @@ pub const Bar: _bindgen_ty_1 = _bindgen_ty_1::Bar;
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum _bindgen_ty_1 { Foo = 0, Bar = 1, }
-pub use _bindgen_ty_1 as Baz;
+pub use self::_bindgen_ty_1 as Baz;
diff --git a/libbindgen/tests/expectations/tests/bitfield_method_mangling.rs b/libbindgen/tests/expectations/tests/bitfield_method_mangling.rs
index b7869bf8..b650a38f 100644
--- a/libbindgen/tests/expectations/tests/bitfield_method_mangling.rs
+++ b/libbindgen/tests/expectations/tests/bitfield_method_mangling.rs
@@ -46,4 +46,4 @@ impl _bindgen_ty_1 {
((val as u32 as u32) << 24u32) & (4278190080usize as u32);
}
}
-pub use _bindgen_ty_1 as mach_msg_type_descriptor_t;
+pub use self::_bindgen_ty_1 as mach_msg_type_descriptor_t;
diff --git a/libbindgen/tests/expectations/tests/inherit_typedef.rs b/libbindgen/tests/expectations/tests/inherit_typedef.rs
index b66cb724..2b974223 100644
--- a/libbindgen/tests/expectations/tests/inherit_typedef.rs
+++ b/libbindgen/tests/expectations/tests/inherit_typedef.rs
@@ -17,7 +17,7 @@ fn bindgen_test_layout_Foo() {
impl Clone for Foo {
fn clone(&self) -> Self { *self }
}
-pub use Foo as TypedefedFoo;
+pub use self::Foo as TypedefedFoo;
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Bar {
diff --git a/libbindgen/tests/expectations/tests/union_fields.rs b/libbindgen/tests/expectations/tests/union_fields.rs
index 655a30ff..21d87919 100644
--- a/libbindgen/tests/expectations/tests/union_fields.rs
+++ b/libbindgen/tests/expectations/tests/union_fields.rs
@@ -44,4 +44,4 @@ fn bindgen_test_layout__bindgen_ty_1() {
impl Clone for _bindgen_ty_1 {
fn clone(&self) -> Self { *self }
}
-pub use _bindgen_ty_1 as nsStyleUnion;
+pub use self::_bindgen_ty_1 as nsStyleUnion;
diff --git a/libbindgen/tests/expectations/tests/unknown_attr.rs b/libbindgen/tests/expectations/tests/unknown_attr.rs
index 8ed508c5..541bee5d 100644
--- a/libbindgen/tests/expectations/tests/unknown_attr.rs
+++ b/libbindgen/tests/expectations/tests/unknown_attr.rs
@@ -13,4 +13,4 @@ pub struct _bindgen_ty_1 {
impl Clone for _bindgen_ty_1 {
fn clone(&self) -> Self { *self }
}
-pub use _bindgen_ty_1 as max_align_t;
+pub use self::_bindgen_ty_1 as max_align_t;