Auto merge of #1444 - scoopr:fix_noisy, r=emilio
Fix noisy errors
This silences errors from template functions and dependant types.
diff --git a/src/ir/context.rs b/src/ir/context.rs
index bdf3842..c0f9246 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -2160,16 +2160,21 @@
::clang_sys::CXCursor_Namespace,
"Be a nice person"
);
+
+ let mut module_name = None;
+ let spelling = cursor.spelling();
+ if !spelling.is_empty()
+ {
+ module_name = Some(spelling)
+ }
+
let tokens = match cursor.tokens() {
Some(tokens) => tokens,
- None => return (None, ModuleKind::Normal),
+ None => return (module_name, ModuleKind::Normal),
};
-
let mut iter = tokens.iter();
let mut kind = ModuleKind::Normal;
let mut found_namespace_keyword = false;
- let mut module_name = None;
-
while let Some(token) = iter.next() {
match &*token.spelling {
"inline" => {
@@ -2195,7 +2200,9 @@
break;
}
name if found_namespace_keyword => {
- module_name = Some(name.to_owned());
+ if module_name.is_none() {
+ module_name = Some(name.to_owned());
+ }
break;
}
_ => {
diff --git a/tests/expectations/tests/namespace.rs b/tests/expectations/tests/namespace.rs
index 726383d..dc51640 100644
--- a/tests/expectations/tests/namespace.rs
+++ b/tests/expectations/tests/namespace.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![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 {
@@ -19,7 +24,7 @@
pub fn in_whatever();
}
}
- pub mod _bindgen_mod_id_13 {
+ pub mod _bindgen_mod_id_17 {
#[allow(unused_imports)]
use self::super::super::root;
#[repr(C)]
@@ -49,7 +54,7 @@
#[repr(C)]
#[derive(Debug)]
pub struct C<T> {
- pub _base: root::_bindgen_mod_id_13::A,
+ pub _base: root::_bindgen_mod_id_17::A,
pub m_c: T,
pub m_c_ptr: *mut T,
pub m_c_arr: [T; 10usize],
@@ -88,4 +93,20 @@
pub fn barr() -> root::C<f32>;
}
}
+ pub mod foobar {
+ #[allow(unused_imports)]
+ use self::super::super::root;
+ extern "C" {
+ #[link_name = "\u{1}_ZN6foobar3fooEv"]
+ pub fn foo();
+ }
+ }
+ pub mod faraway {
+ #[allow(unused_imports)]
+ use self::super::super::root;
+ extern "C" {
+ #[link_name = "\u{1}_ZN7faraway3barEv"]
+ pub fn bar();
+ }
+ }
}
diff --git a/tests/headers/namespace.hpp b/tests/headers/namespace.hpp
index 408207f..a8e6f8e 100644
--- a/tests/headers/namespace.hpp
+++ b/tests/headers/namespace.hpp
@@ -40,3 +40,12 @@
C<float> barr(); // <- This is the problematic one
}
+
+#define NAMESPACE foobar
+namespace NAMESPACE {
+ void foo();
+}
+
+#include "namespace/nsbegin.h"
+void bar();
+#include "namespace/nsend.h"
diff --git a/tests/headers/namespace/nsbegin.h b/tests/headers/namespace/nsbegin.h
new file mode 100644
index 0000000..47a51c9
--- /dev/null
+++ b/tests/headers/namespace/nsbegin.h
@@ -0,0 +1 @@
+namespace faraway {
diff --git a/tests/headers/namespace/nsend.h b/tests/headers/namespace/nsend.h
new file mode 100644
index 0000000..5c34318
--- /dev/null
+++ b/tests/headers/namespace/nsend.h
@@ -0,0 +1 @@
+}