summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-11-16 14:09:38 +0100
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-11-16 14:55:33 +0100
commit2468fb2baf502159558e83a9457d5d74f793c6fb (patch)
treed949350b0da2742faf9863c19b25e1226af80baa
parent9380ed5a917b92858cc61b38ec2e300ab08a2337 (diff)
ir: context: fall back to use the declaration as a key when there's no USR.
Apparently MSVC isn't that good at giving us USRs... Fixes #271
-rw-r--r--libbindgen/src/ir/context.rs2
-rw-r--r--libbindgen/tests/expectations/tests/msvc-no-usr.rs19
-rw-r--r--libbindgen/tests/headers/msvc-no-usr.hpp8
3 files changed, 28 insertions, 1 deletions
diff --git a/libbindgen/src/ir/context.rs b/libbindgen/src/ir/context.rs
index a1ec8c70..bda3e3c8 100644
--- a/libbindgen/src/ir/context.rs
+++ b/libbindgen/src/ir/context.rs
@@ -222,7 +222,7 @@ impl<'ctx> BindgenContext<'ctx> {
error!("Valid declaration with no USR: {:?}, {:?}",
declaration,
location);
- return;
+ TypeKey::Declaration(declaration)
};
let old = self.types.insert(key, id);
diff --git a/libbindgen/tests/expectations/tests/msvc-no-usr.rs b/libbindgen/tests/expectations/tests/msvc-no-usr.rs
new file mode 100644
index 00000000..8cab8cdc
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/msvc-no-usr.rs
@@ -0,0 +1,19 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct A {
+ pub foo: usize,
+}
+#[test]
+fn bindgen_test_layout_A() {
+ assert_eq!(::std::mem::size_of::<A>() , 8usize);
+ assert_eq!(::std::mem::align_of::<A>() , 8usize);
+}
+impl Clone for A {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/headers/msvc-no-usr.hpp b/libbindgen/tests/headers/msvc-no-usr.hpp
new file mode 100644
index 00000000..b15e49f5
--- /dev/null
+++ b/libbindgen/tests/headers/msvc-no-usr.hpp
@@ -0,0 +1,8 @@
+
+typedef unsigned long long size_t;
+
+class A {
+ const size_t foo;
+
+ A() : foo(5) {}
+};