-
Notifications
You must be signed in to change notification settings - Fork 747
First steps to fix issue #57 #282
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
First steps to fix issue #57 #282
Conversation
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @emilio (or someone else) soon. |
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 looks good! A few comments
@@ -656,8 +656,30 @@ impl CodeGenerator for CompInfo { | |||
// | |||
// TODO: Generate layout tests for template specializations, yay! | |||
if self.has_non_type_template_params() || |
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.
You should still bail out if has_non_type_template_params
, I don't think a lot of stuff will happen, since they probably don't have layout, but still seems a bit clearer.
let canonical_name = item.canonical_name(ctx); | ||
|
||
if let Some(layout) = layout { | ||
let fn_name = format!("bindgen_test_layout_template_{}", canonical_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.
As discussed before, this will probably need to include the type id of the specialization, or similar, so it generates a totally unique name.
::$prefix::mem::align_of::<$ident>()); | ||
let size = layout.size; | ||
let align = layout.align; | ||
let item = quote_item!(ctx.ext_cx(), |
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.
Probably we should try to reuse this code with the other tests, that way it's easier to change in the future if needed.
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.
The rest looks neat! I'd really like to move the generation of the function to the test function, but looks great otherwise :)
@@ -655,9 +655,43 @@ impl CodeGenerator for CompInfo { | |||
// also don't output template specializations, neither total or partial. | |||
// | |||
// TODO: Generate layout tests for template specializations, yay! |
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: Remove this TODO
.
@@ -655,9 +655,43 @@ impl CodeGenerator for CompInfo { | |||
// also don't output template specializations, neither total or partial. | |||
// | |||
// TODO: Generate layout tests for template specializations, yay! | |||
|
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: And this newline.
} | ||
} | ||
|
||
let fn_name = format!("bindgen_test_layout_template_{}{}", canonical_name, types); |
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 is ok probably, but we could just have done something like:
let fn_name = format!("__bindgen_test_layout_template_{}", item.id().as_usize());
This way is prettier, though a bit more likely to cause conflicts.
@@ -655,9 +655,43 @@ impl CodeGenerator for CompInfo { | |||
// also don't output template specializations, neither total or partial. | |||
// | |||
// TODO: Generate layout tests for template specializations, yay! | |||
|
|||
// TODO (imp): I will keep it like that right now and move it to function later | |||
if self.has_non_type_template_params() || |
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.
Please divide this condition as discussed earlier:
if self.has_non_type_template_params() {
return;
}
if self.is_template_specialization() {
// ...
return;
}
I applied changes from your review. If it's fine I guess I will rebase it and can work on something else in this project. |
Looks good, thanks! @bors-servo: r+ |
📌 Commit 5c76483 has been approved by |
☀️ Test successful - status-travis |
This should generate tests for fully specialized templates.
TODO:
r? @emilio