-
Notifications
You must be signed in to change notification settings - Fork 748
ir: Handle properly template alias instantiations in clang >3.9 #696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d01e10e
to
827254b
Compare
r? @fitzgen |
827254b
to
f31a88c
Compare
With this and #694, the following is the test difference: diff --git a/tests/expectations/tests/objc_template.rs b/tests/expectations/tests/objc_template.rs
index e5a874c6..95d12ff6 100644
--- a/tests/expectations/tests/objc_template.rs
+++ b/tests/expectations/tests/objc_template.rs
@@ -11,8 +11,8 @@ extern crate objc;
pub type id = *mut objc::runtime::Object;
pub trait Foo {
unsafe fn get(self)
- -> id;
+ -> *mut ObjectType;
}
impl Foo for id {
- unsafe fn get(self) -> id { msg_send!(self , get) }
+ unsafe fn get(self) -> *mut ObjectType { msg_send!(self , get) }
}
diff --git a/tests/expectations/tests/template.rs b/tests/expectations/tests/template.rs
index d4f81711..00061ecd 100644
--- a/tests/expectations/tests/template.rs
+++ b/tests/expectations/tests/template.rs
@@ -256,7 +256,18 @@ fn __bindgen_test_layout_Foo_instantiation_95() {
Foo<::std::os::raw::c_int> ) ));
}
#[test]
-fn __bindgen_test_layout_Rooted_instantiation_106() {
+fn __bindgen_test_layout_Foo_instantiation_101() {
+ assert_eq!(::std::mem::size_of::<Foo<::std::os::raw::c_int>>() , 24usize ,
+ concat ! (
+ "Size of template specialization: " , stringify ! (
+ Foo<::std::os::raw::c_int> ) ));
+ assert_eq!(::std::mem::align_of::<Foo<::std::os::raw::c_int>>() , 8usize ,
+ concat ! (
+ "Alignment of template specialization: " , stringify ! (
+ Foo<::std::os::raw::c_int> ) ));
+}
+#[test]
+fn __bindgen_test_layout_Rooted_instantiation_111() {
assert_eq!(::std::mem::size_of::<Rooted<*mut ::std::os::raw::c_void>>() ,
24usize , concat ! (
"Size of template specialization: " , stringify ! (
@@ -267,7 +278,7 @@ fn __bindgen_test_layout_Rooted_instantiation_106() {
Rooted<*mut ::std::os::raw::c_void> ) ));
}
#[test]
-fn __bindgen_test_layout_WithDtor_instantiation_114() {
+fn __bindgen_test_layout_WithDtor_instantiation_123() {
assert_eq!(::std::mem::size_of::<WithDtor<::std::os::raw::c_int>>() ,
4usize , concat ! (
"Size of template specialization: " , stringify ! (
diff --git a/tests/expectations/tests/type_alias_template_specialized.rs b/tests/expectations/tests/type_alias_template_specialized.rs
index 20665af6..feb2a45e 100644
--- a/tests/expectations/tests/type_alias_template_specialized.rs
+++ b/tests/expectations/tests/type_alias_template_specialized.rs
@@ -5,9 +5,9 @@
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Copy)]
pub struct Rooted {
- pub ptr: ::std::os::raw::c_int,
+ pub ptr: MaybeWrapped<::std::os::raw::c_int>,
}
#[test]
fn bindgen_test_layout_Rooted() {
@@ -24,5 +24,8 @@ fn bindgen_test_layout_Rooted() {
impl Clone for Rooted {
fn clone(&self) -> Self { *self }
}
+impl Default for Rooted {
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+}
/// <div rustbindgen replaces="MaybeWrapped"></div>
pub type MaybeWrapped<a> = a; |
One of those is #695, the other changes are more correct AFAIK. |
This fixes tests/expectations/tests/type_alias_template_specialized.rs in those clang versions (without regressions, hopefully), and makes the behavior the proper one, without needing replacements.
f31a88c
to
b2e5613
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! THanks!
@bors-servo r+ |
📌 Commit b2e5613 has been approved by |
ir: Handle properly template alias instantiations in clang >3.9
☀️ Test successful - status-travis |
No description provided.