summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/ISSUE_TEMPLATE.md9
-rw-r--r--src/ir/item.rs12
-rw-r--r--tests/expectations/tests/inline_namespace_no_ns_enabled.rs34
-rw-r--r--tests/headers/inline_namespace_no_ns_enabled.hpp18
4 files changed, 71 insertions, 2 deletions
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index c10fab0f..02fe3cde 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -1,7 +1,14 @@
### Input C/C++ Header
```C++
-// Insert your (minimal) C/C++ header here.
+// Insert your minimal C or C++ header here.
+//
+// It should *NOT* have any `#include`s! Not all systems have the same header
+// files, and therefore any `#include` harms reproducibility. Additionally,
+// the test case isn't minimal since the included file almost assuredly
+// contains things that aren't necessary to reproduce the bug, and makes
+// tracking it down much more difficult. If necessary, see
+// https://github.com/servo/rust-bindgen/blob/master/CONTRIBUTING.md#using-creduce-to-minimize-test-cases
```
### Bindgen Invocation
diff --git a/src/ir/item.rs b/src/ir/item.rs
index 3564c6e8..cfda4953 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -768,9 +768,19 @@ impl Item {
.ancestors(ctx)
.filter(|id| *id != ctx.root_module())
.take_while(|id| {
- // Stop iterating ancestors once we reach a namespace.
+ // Stop iterating ancestors once we reach a non-inline namespace
+ // when opt.within_namespaces is set.
!opt.within_namespaces || !ctx.resolve_item(*id).is_module()
})
+ .filter(|id| {
+ if !ctx.options().conservative_inline_namespaces {
+ if let ItemKind::Module(ref module) = *ctx.resolve_item(*id).kind() {
+ return !module.is_inline();
+ }
+ }
+
+ true
+ })
.map(|id| {
let item = ctx.resolve_item(id);
let target = ctx.resolve_item(item.name_target(ctx));
diff --git a/tests/expectations/tests/inline_namespace_no_ns_enabled.rs b/tests/expectations/tests/inline_namespace_no_ns_enabled.rs
new file mode 100644
index 00000000..c2592e57
--- /dev/null
+++ b/tests/expectations/tests/inline_namespace_no_ns_enabled.rs
@@ -0,0 +1,34 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
+
+#[repr(C)]
+#[derive(Debug)]
+pub struct std_basic_string<CharT> {
+ pub hider: std_basic_string_Alloc_hider,
+ pub length: ::std::os::raw::c_ulong,
+ pub __bindgen_anon_1: std_basic_string__bindgen_ty_1<CharT>,
+ pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<CharT>>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct std_basic_string_Alloc_hider {
+ pub storage: *mut ::std::os::raw::c_void,
+}
+impl Default for std_basic_string_Alloc_hider {
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct std_basic_string__bindgen_ty_1<CharT> {
+ pub inline_storage: [CharT; 4usize],
+ pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<CharT>>,
+}
+impl <CharT> Default for std_basic_string__bindgen_ty_1<CharT> {
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+}
+impl <CharT> Default for std_basic_string<CharT> {
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+}
diff --git a/tests/headers/inline_namespace_no_ns_enabled.hpp b/tests/headers/inline_namespace_no_ns_enabled.hpp
new file mode 100644
index 00000000..30cd4e9b
--- /dev/null
+++ b/tests/headers/inline_namespace_no_ns_enabled.hpp
@@ -0,0 +1,18 @@
+// bindgen-flags: -- -std=c++11
+
+namespace std {
+inline namespace __cxx11 {
+
+template<typename CharT>
+class basic_string {
+ struct Alloc_hider {
+ void* storage;
+ } hider;
+ unsigned long length;
+ struct {
+ CharT inline_storage[4];
+ };
+};
+
+}
+}