Skip to content
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

codegen: Avoid generating invalid Rust code when a struct is not properly aligned. #413

Merged
merged 1 commit into from
Jan 23, 2017

Conversation

emilio
Copy link
Contributor

@emilio emilio commented Jan 21, 2017

r? @fitzgen

cc #412

@highfive
Copy link

warning Warning warning

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

impl CanDeriveDebug for Opaque {
type Extra = ();

fn can_derive_debug(&self, _: &BindgenContext, _: ()) -> bool {
let size_divisor = cmp::max(1, self.0.align);
self.0.size / size_divisor <= RUST_DERIVE_IN_ARRAY_LIMIT
self.array_size().map_or(false, |size| size <= RUST_DERIVE_IN_ARRAY_LIMIT)
Copy link
Member

Choose a reason for hiding this comment

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

This stuff is great :)

@fitzgen
Copy link
Member

fitzgen commented Jan 23, 2017

@bors-servo r+

@bors-servo
Copy link

📌 Commit 30a4722 has been approved by fitzgen

@bors-servo
Copy link

⚡ Test exempted - status

@bors-servo bors-servo merged commit 30a4722 into rust-lang:master Jan 23, 2017
bors-servo pushed a commit that referenced this pull request Jan 23, 2017
codegen: Avoid generating invalid Rust code when a struct is not properly aligned.

r? @fitzgen

cc #412
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