Skip to content

codegen: Don't assume unsized structs have address. #552

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 1 commit into from
Mar 6, 2017

Conversation

emilio
Copy link
Contributor

@emilio emilio commented Mar 3, 2017

Per C semantics, they may not.

r? @fitzgen

fields.push(field);
let has_address = match layout {
Some(l) => l.size != 0,
None => true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Little shorter variant: layout.map_or(true, |l| l.size != 0)

Copy link
Member

Choose a reason for hiding this comment

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

+1 for the shorter variant.

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Thanks! :)

fields.push(field);
let has_address = match layout {
Some(l) => l.size != 0,
None => true,
Copy link
Member

Choose a reason for hiding this comment

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

+1 for the shorter variant.

@@ -0,0 +1 @@
struct Foo {};
Copy link
Member

Choose a reason for hiding this comment

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

I know we have tests for this intermingled here and there elsewhere, but it would be nice to have a C++ companion for this test that has the same contents but with a .hpp extension.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@emilio
Copy link
Contributor Author

emilio commented Mar 6, 2017

@bors-servo r=fitzgen

@bors-servo
Copy link

📌 Commit 5982cd3 has been approved by fitzgen

@bors-servo
Copy link

⌛ Testing commit 5982cd3 with merge b821252...

bors-servo pushed a commit that referenced this pull request Mar 6, 2017
codegen: Don't assume unsized structs have address.

Per C semantics, they may not.

r? @fitzgen
@bors-servo
Copy link

☀️ Test successful - status-travis
Approved by: fitzgen
Pushing b821252 to master...

@bors-servo bors-servo merged commit 5982cd3 into rust-lang:master Mar 6, 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.

5 participants