Skip to content

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

Merged
merged 4 commits into from
Nov 21, 2016
Merged

First steps to fix issue #57 #282

merged 4 commits into from
Nov 21, 2016

Conversation

impowski
Copy link
Contributor

@impowski impowski commented Nov 18, 2016

This should generate tests for fully specialized templates.
TODO:

  • Tests

r? @emilio

@highfive
Copy link

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.

Copy link
Contributor

@emilio emilio left a 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() ||
Copy link
Contributor

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);
Copy link
Contributor

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(),
Copy link
Contributor

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.

Copy link
Contributor

@emilio emilio left a 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!
Copy link
Contributor

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!

Copy link
Contributor

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);
Copy link
Contributor

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() ||
Copy link
Contributor

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;
}

@impowski
Copy link
Contributor Author

impowski commented Nov 21, 2016

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.
r? @emilio

@emilio
Copy link
Contributor

emilio commented Nov 21, 2016

Looks good, thanks!

@bors-servo: r+

@bors-servo
Copy link

📌 Commit 5c76483 has been approved by emilio

@bors-servo
Copy link

⌛ Testing commit 5c76483 with merge ec9852a...

bors-servo pushed a commit that referenced this pull request Nov 21, 2016
First steps to fix issue #57

This should generate tests for fully specialized templates.
TODO:
- [x] Tests

r? @emilio
@bors-servo
Copy link

☀️ Test successful - status-travis

@bors-servo bors-servo merged commit 5c76483 into rust-lang:master Nov 21, 2016
@impowski impowski deleted the layout_template_specializations branch November 22, 2016 07:50
@impowski impowski restored the layout_template_specializations branch November 22, 2016 07:55
@impowski impowski deleted the layout_template_specializations branch November 22, 2016 07:55
luser pushed a commit to luser/rust-bindgen that referenced this pull request Mar 27, 2017
luser pushed a commit to luser/rust-bindgen that referenced this pull request Mar 27, 2017
luser pushed a commit to luser/rust-bindgen that referenced this pull request Mar 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants