-
Notifications
You must be signed in to change notification settings - Fork 723
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
Use fully disambiguated name instead of a number for layout tests (fixes #394) #829
Conversation
df88db7
to
fbb68d4
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.
CI is red, you need to update the platform-specific tests (you can do it using the diffs from travis).
src/ir/item.rs
Outdated
/// Create a fully disambiguated name for an item, including template | ||
/// parameters if it is a type | ||
pub fn full_disambiguated_name(&self, ctx: &BindgenContext) -> String { | ||
let mut s = "".into(); |
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.
nit: just String::new()
?
src/ir/item.rs
Outdated
/// Helper function for full_disambiguated_name | ||
fn push_disambiguated_name(&self, ctx: &BindgenContext, to: &mut String, level: u8) { | ||
to.push_str(&self.canonical_name(ctx)); | ||
match *self.kind() { |
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.
Seems like a case for either if let
, or:
let ty = match *self.kind() {
ItemKind::Type(ref ty) => ty,
_ => return,
};
// ...
@@ -768,7 +768,7 @@ impl CodeGenerator for TemplateInstantiation { | |||
let size = layout.size; | |||
let align = layout.align; | |||
|
|||
let name = item.canonical_name(ctx); | |||
let name = item.full_disambiguated_name(ctx); | |||
let mut fn_name = format!("__bindgen_test_layout_{}_instantiation", name); | |||
let times_seen = result.overload_number(&fn_name); |
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.
I guess you can remove this overload_number
stuff and so on?
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.
src/ir/item.rs
Outdated
TypeKind::TemplateInstantiation(ref inst) => { | ||
to.push_str(&format!("_open{}_", level)); | ||
for arg in inst.template_arguments() { | ||
ctx.resolve_item(*arg).push_disambiguated_name(ctx, to, level + 1); |
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.
This won't work for nested templates, afaict, because you don't handle ResolvedTypeRef
, or anything like that.
I still think that using the C++ mangling would be best (they already solved this exact unique-ness issue), do you remember why we weren't getting the mangling for template instantiations, @emilio ? Was it just that we weren't saving the information? Anyways, cancelling my review, since Emilio is on it. |
cbbe118
to
19b69fb
Compare
Looks like the libclang-4 expectations need to be updated: ---- header_issue_769_bad_instantiation_test_hpp stdout ----
/home/travis/build/servo/rust-bindgen/tests/headers/issue-769-bad-instantiation-test.hpp:9:19: warning: alias declarations are a C++11 extension [-Wc++11-extensions], err: false
/home/travis/build/servo/rust-bindgen/tests/headers/issue-769-bad-instantiation-test.hpp:10:25: warning: alias declarations are a C++11 extension [-Wc++11-extensions], err: false
diff expected generated
--- expected: "/home/travis/build/servo/rust-bindgen/tests/expectations/tests/libclang-4/issue-769-bad-instantiation-test.rs"
+++ generated from: "/home/travis/build/servo/rust-bindgen/tests/headers/issue-769-bad-instantiation-test.hpp"
/* automatically generated by rust-bindgen */
#![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 {
#[allow(unused_imports)]
use self::super::root;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Rooted<T> {
pub member: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
impl <T> Default for Rooted<T> {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
pub type AutoValueVector_Alias = ::std::os::raw::c_int;
#[test]
fn __bindgen_test_layout_Rooted_open0_int_close0_instantiation() {
assert_eq!(::std::mem::size_of::<root::Rooted<::std::os::raw::c_int>>()
, 4usize , concat ! (
"Size of template specialization: " , stringify ! (
root::Rooted<::std::os::raw::c_int> ) ));
assert_eq!(::std::mem::align_of::<root::Rooted<::std::os::raw::c_int>>()
, 4usize , concat ! (
"Alignment of template specialization: " , stringify ! (
root::Rooted<::std::os::raw::c_int> ) ));
}
#[test]
- fn __bindgen_test_layout_Rooted_open0_AutoValueVector_Alias_close0_instantiation() {
+ fn __bindgen_test_layout_Rooted_open0_AutoValueVector_Alias_close0_instantiation() {
assert_eq!(::std::mem::size_of::<root::Rooted<root::AutoValueVector_Alias>>()
, 4usize , concat ! (
"Size of template specialization: " , stringify ! (
root::Rooted<root::AutoValueVector_Alias> ) ));
assert_eq!(::std::mem::align_of::<root::Rooted<root::AutoValueVector_Alias>>()
, 4usize , concat ! (
"Alignment of template specialization: " , stringify ! (
root::Rooted<root::AutoValueVector_Alias> ) ));
}
} |
Passes now |
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.
r=me
@bors-servo r+ |
📌 Commit 3dedc2c has been approved by |
☀️ Test successful - status-travis |
Bump to 0.28 Brings in #822 which unblocks https://bugzilla.mozilla.org/show_bug.cgi?id=1366956, and also #829 which should greatly reduce merge conflicts in checked in bindings.
These numbers cause tons of churn in the diffs for checked in bindings.
r? @fitzgen