Skip to content

Translate zero-sized return types as void #30938

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
Jan 17, 2016
Merged

Conversation

dotdash
Copy link
Contributor

@dotdash dotdash commented Jan 15, 2016

The only way to get a value for a zero-sized type is undef, so
there's really no point in actually having a return type other than
void for such types. Also, while the comment in return_type_is_void
mentioned something about aiding C ABI support, @eddyb correctly
pointed out on IRC that there is no such thing as a zero-sized type in
C. And even with clang, which allows empty structs, those get
translated as void return types as well.

Fixes #28766

@rust-highfive
Copy link
Contributor

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

The only way to get a value for a zero-sized type is `undef`, so
there's really no point in actually having a return type other than
void for such types. Also, while the comment in return_type_is_void
mentioned something about aiding C ABI support, @eddyb correctly
pointed out on IRC that there is no such thing as a zero-sized type in
C. And even with clang, which allows empty structs, those get
translated as void return types as well.

Fixes rust-lang#28766
@eddyb
Copy link
Member

eddyb commented Jan 16, 2016

@bors r+

@bors
Copy link
Collaborator

bors commented Jan 16, 2016

📌 Commit f10af2e has been approved by eddyb

Manishearth added a commit to Manishearth/rust that referenced this pull request Jan 17, 2016
The only way to get a value for a zero-sized type is `undef`, so
there's really no point in actually having a return type other than
void for such types. Also, while the comment in return_type_is_void
mentioned something about aiding C ABI support, @eddyb correctly
pointed out on IRC that there is no such thing as a zero-sized type in
C. And even with clang, which allows empty structs, those get
translated as void return types as well.

Fixes rust-lang#28766
bors added a commit that referenced this pull request Jan 17, 2016
@bors bors merged commit f10af2e into rust-lang:master Jan 17, 2016
@dotdash dotdash deleted the zst_void branch January 31, 2016 15:28
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