-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Allow #[repr(i32)] for univariant enum #31232
Conversation
``` #[repr(i32)] enum Univariant { X = 17 } ``` Fixes rust-lang#10292
r? @nrc (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -4250,14 +4250,9 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, | |||
let def_id = ccx.tcx.map.local_def_id(id); | |||
let hint = *ccx.tcx.lookup_repr_hints(def_id).get(0).unwrap_or(&attr::ReprAny); | |||
|
|||
if hint != attr::ReprAny && vs.len() <= 1 { | |||
if vs.len() == 1 { | |||
span_err!(ccx.tcx.sess, sp, E0083, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should remove E0083 along with this change
I am amazed this worked without changes to trans. cc @rust-lang/compiler and @luqmana r+ if no one objects and with the error description removed. |
6c2f78f
to
69c6292
Compare
Removed E0083. |
Why was this ever illegal in the first place? It makes no sense to me. |
Yea, looks good to me. Not sure why it was disallowed but should be fine if it builds and passes tests. |
span_err!(ccx.tcx.sess, sp, E0084, | ||
"unsupported representation for zero-variant enum"); | ||
}; | ||
if hint != attr::ReprAny && vs.len() == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vs.is_empty()
69c6292
to
641267e
Compare
Updated with |
No objections. |
The reason this doesn't require any |
Thanks all! (And especially @stepancheg for the PR in the first place and some patience for the r+). @bors: r+ |
📌 Commit 641267e has been approved by |
``` enum Univariant { X = 17 } ``` Fixes #10292
Fixes #10292