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 discriminants values can be given different types #8761

Closed
huonw opened this issue Aug 26, 2013 · 2 comments · Fixed by #16568
Closed

C-like enums discriminants values can be given different types #8761

huonw opened this issue Aug 26, 2013 · 2 comments · Fixed by #16568
Labels
A-typesystem Area: The type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@huonw
Copy link
Member

huonw commented Aug 26, 2013

The following compiles fine, even though the discriminants are different types (I know that the annotations currently do nothing).

enum Foo { A = 1i64, B = 2u8 }

fn main() {}
@eminence
Copy link
Contributor

Using the latest master (e2273d9), your example produces an error message that looks correct to me:

est.rs:1:16: 1:20 error: mismatched types: expected `int` but found `i64` (expected int but found i64)
test.rs:1 enum Foo { A = 1i64, B = 2u8 }
                         ^~~~
test.rs:1:26: 1:29 error: mismatched types: expected `int` but found `u8` (expected int but found u8)
test.rs:1 enum Foo { A = 1i64, B = 2u8 }
                                   ^~~

@alexcrichton
Copy link
Member

Flagging as needstest

bors added a commit that referenced this issue Aug 18, 2014
xFrednet pushed a commit to xFrednet/rust that referenced this issue May 21, 2022
`undocumented_unsafe_blocks` does not trigger on unsafe trait impls

Closes rust-lang#8505

changelog: This lint checks unsafe impls NOT from macro expansions and checks ones in macro declarations.
~~`unsafe impl`s from macro invocations don't trigger the lint for now.~~
~~This lint checks unsafe impls from/not from macro expansions~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants