Skip to content

Derive debug and opaque types #847

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 6 commits into from
Jul 24, 2017

Conversation

fitzgen
Copy link
Member

@fitzgen fitzgen commented Jul 24, 2017

See each commit for details.

Follow up to #842.

r? @emilio or @Manishearth

@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@fitzgen
Copy link
Member Author

fitzgen commented Jul 24, 2017

I think I may need to update some libclang version specific tests once I get word back from Travis CI...

let layout_can_derive = ty.layout(self.ctx).map_or(true, |l| {
l.opaque().can_trivially_derive_debug(self.ctx, ())
});
if layout_can_derive {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: return if?

};

// This should not end up deriving Debug because its `mBlah` field cannot derive
// Debug because the instantiation's definition cannot derive Debug.
class ContainsOpaqueTemplate {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the point of the test is that we derived debug for the instantiation if we could, could you add that back, maybe as another different test-case?

/* automatically generated by rust-bindgen */


#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sure, disregard my previous comment :-)

fitzgen added 6 commits July 24, 2017 12:42
There are lots of different ways that a type can end up being opaque, and it is
best to handle all the ways in one fell swoop, rather than check each different
ways (for example, if a struct has non-type template params, if a template
instantiation's template definition has them, etc...) for each different type
kind.
Useful for debugging when constraints go wrong.
And also not just fields, but also base members.
@fitzgen fitzgen force-pushed the derive-debug-opaque-types branch from 162a34c to 684fc38 Compare July 24, 2017 19:45
@fitzgen
Copy link
Member Author

fitzgen commented Jul 24, 2017

@bors-servo r=emilio

Thanks for review :)

@bors-servo
Copy link

📌 Commit 684fc38 has been approved by emilio

@bors-servo
Copy link

⌛ Testing commit 684fc38 with merge e9f452b...

bors-servo pushed a commit that referenced this pull request Jul 24, 2017
Derive debug and opaque types

See each commit for details.

Follow up to #842.

r? @emilio or @Manishearth
@bors-servo
Copy link

☀️ Test successful - status-travis
Approved by: emilio
Pushing e9f452b to master...

@bors-servo bors-servo merged commit 684fc38 into rust-lang:master Jul 24, 2017
@fitzgen fitzgen deleted the derive-debug-opaque-types branch July 24, 2017 20:26
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