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

C-like enums don't accept uint discriminants #7994

Closed
kemurphy opened this issue Jul 23, 2013 · 2 comments
Closed

C-like enums don't accept uint discriminants #7994

kemurphy opened this issue Jul 23, 2013 · 2 comments

Comments

@kemurphy
Copy link
Contributor

Currently, the following fails to compile, with errors about expecting int instead of uint:

enum Animal {
  Cat = 0u,
  Dog = 1u
}

Is there any reason why this should be disallowed?

@bluss
Copy link
Member

bluss commented Jul 23, 2013

Linking to issue #1647

kemurphy added a commit to kemurphy/rust that referenced this issue Jul 25, 2013
Infers type of constants used as discriminants and ensures they are
integral, instead of forcing them to be a signed integer.

Also, stores discriminant values as uint instead of int interally and
deals with related fallout.

Fixes issue rust-lang#7994
@pnkfelix
Copy link
Member

Fixed by ba9c3eb

flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 23, 2021
Rustup

r? `@ghost`

changelog: none
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

No branches or pull requests

3 participants