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

Allow #[repr(i32)] for univariant enum #31232

Merged
merged 1 commit into from
Feb 1, 2016

Conversation

stepancheg
Copy link
Contributor

#[repr(i32)]
enum Univariant {
    X = 17
}

Fixes #10292

```
#[repr(i32)]
enum Univariant {
    X = 17
}
```

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

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,
Copy link
Member

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

@nrc
Copy link
Member

nrc commented Jan 27, 2016

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.

@stepancheg
Copy link
Contributor Author

Removed E0083.

@retep998
Copy link
Member

Why was this ever illegal in the first place? It makes no sense to me.

@luqmana
Copy link
Member

luqmana commented Jan 27, 2016

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vs.is_empty()

@stepancheg
Copy link
Contributor Author

Updated with is_empty().

@nagisa
Copy link
Member

nagisa commented Jan 27, 2016

No objections.

@Aatch
Copy link
Contributor

Aatch commented Jan 29, 2016

The reason this doesn't require any trans changes is because the check for C-Like enum happens before the check for single-variant.

@nrc
Copy link
Member

nrc commented Feb 1, 2016

Thanks all! (And especially @stepancheg for the PR in the first place and some patience for the r+).

@bors: r+

@bors
Copy link
Contributor

bors commented Feb 1, 2016

📌 Commit 641267e has been approved by nrc

@bors
Copy link
Contributor

bors commented Feb 1, 2016

⌛ Testing commit 641267e with merge 14dc9fc...

bors added a commit that referenced this pull request Feb 1, 2016
```
enum Univariant {
    X = 17
}
```

Fixes #10292
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.

9 participants