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

Make single-variant "c-like" enums have no size. #20122

Closed
wants to merge 2 commits into from

Conversation

Aatch
Copy link
Contributor

@Aatch Aatch commented Dec 22, 2014

This makes an enum like enum Foo { Foo } be zero-sized. If a
discriminant is set to non-zero, it still treats it as a c-like enum.

Fixes #15747

This makes an enum like `enum Foo { Foo }` be zero-sized. If a
discriminant is set to non-zero, it still treats it as a c-like enum.

Fixes rust-lang#15747
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see CONTRIBUTING.md for more information.

@luqmana
Copy link
Member

luqmana commented Dec 22, 2014

r=me with test.

@Aatch Aatch force-pushed the zero-size-univariant branch from 34d86f0 to 98ae8ad Compare December 22, 2014 04:00
@Aatch
Copy link
Contributor Author

Aatch commented Dec 22, 2014

@luqmana added, despite knowing it will conflict another one of my pull requests >.>

@eddyb eddyb assigned luqmana and unassigned brson Dec 22, 2014
@alexcrichton
Copy link
Member

I think this has a failure in the debuginfo tests:

failures:

---- [debuginfo-gdb] debuginfo/c-style-enum.rs stdout ----
        NOTE: compiletest thinks it is using GDB version 7.7

error: line not found in debugger output: $1 = TheOnlyVariant

status: exit code: 0
command: gdb -quiet -batch -nx -command=x86_64-unknown-linux-gnu/test/debuginfo-gdb/c-style-enum.debugger.script
stdout:
------------------------------------------
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Breakpoint 1 at 0x988: file src/test/debuginfo/c-style-enum.rs, line 156.

------------------------------------------
stderr:
------------------------------------------
x86_64-unknown-linux-gnu/test/debuginfo-gdb/c-style-enum.debugger.script:8: Error in sourced command file:
No symbol "c-style-enum::SINGLE_VARIANT" in current context.

------------------------------------------

thread '[debuginfo-gdb] debuginfo/c-style-enum.rs' panicked at 'explicit panic', /home/alex/code/rust3/src/compiletest/runtest.rs:1487



failures:
    [debuginfo-gdb] debuginfo/c-style-enum.rs

test result: FAILED. 91 passed; 1 failed; 4 ignored; 0 measured

@alexcrichton
Copy link
Member

Closing due to inactivity, but feel free to reopen with a rebase!

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.

Allow single-value enum types to have size 0
6 participants