about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-08-18 01:00:17 +0000
committerbors <bors@rust-lang.org>2021-08-18 01:00:17 +0000
commit02b27f1e70fc60a8f2aa0982e80d7cde5889112e (patch)
tree065c73132ec35f5b5bd53d02f0734b81cbf444ed /src/test/ui/parser
parentadf168844791b213383b18d10515eaee88695f7d (diff)
parent7a62f29f3171767090949778ce0f161e930706b9 (diff)
downloadrust-02b27f1e70fc60a8f2aa0982e80d7cde5889112e.tar.gz
rust-02b27f1e70fc60a8f2aa0982e80d7cde5889112e.zip
Auto merge of #86860 - fee1-dead:stabilize, r=LeSeulArtichaut
Stabilize `arbitrary_enum_discriminant`

Closes #60553.

----

## Stabilization Report

_copied from https://github.com/rust-lang/rust/issues/60553#issuecomment-865922311_

### Summary

Enables a user to specify *explicit* discriminants on arbitrary enums.

Previously, this was hard to achieve:

```rust
#[repr(u8)]
enum Foo {
    A(u8) = 0,
    B(i8) = 1,
    C(bool) = 42,
}
```

Someone would need to add 41 hidden variants in between as a workaround with implicit discriminants.

In conjunction with [RFC 2195](https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md), this feature would provide more flexibility for FFI and unsafe code involving enums.

### Test cases

Most tests are in [`src/test/ui/enum-discriminant`](https://github.com/rust-lang/rust/tree/master/src/test/ui/enum-discriminant), there are two [historical](https://github.com/rust-lang/rust/blob/master/src/test/ui/parser/tag-variant-disr-non-nullary.rs) [tests](https://github.com/rust-lang/rust/blob/master/src/test/ui/parser/issue-17383.rs) that are now covered by the feature (removed by this pr due to them being obsolete).

### Edge cases

The feature is well defined and does not have many edge cases.
One [edge case](https://github.com/rust-lang/rust/issues/70509) was related to another unstable feature named `repr128` and is resolved.

### Previous PRs

The [implementation PR](https://github.com/rust-lang/rust/pull/60732) added documentation to the Unstable Book, https://github.com/rust-lang/reference/pull/1055 was opened as a continuation of https://github.com/rust-lang/reference/pull/639.

### Resolution of unresolved questions

The questions are resolved in https://github.com/rust-lang/rust/issues/60553#issuecomment-511235271.

----

(someone please add `needs-fcp`)
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/issue-17383.rs7
-rw-r--r--src/test/ui/parser/issue-17383.stderr15
-rw-r--r--src/test/ui/parser/tag-variant-disr-non-nullary.rs12
-rw-r--r--src/test/ui/parser/tag-variant-disr-non-nullary.stderr25
4 files changed, 0 insertions, 59 deletions
diff --git a/src/test/ui/parser/issue-17383.rs b/src/test/ui/parser/issue-17383.rs
deleted file mode 100644
index 7bf0e64f2c0..00000000000
--- a/src/test/ui/parser/issue-17383.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-enum X {
-    A = 3,
-    //~^ ERROR custom discriminant values are not allowed in enums with tuple or struct variants
-    B(usize)
-}
-
-fn main() {}
diff --git a/src/test/ui/parser/issue-17383.stderr b/src/test/ui/parser/issue-17383.stderr
deleted file mode 100644
index 265d6e14866..00000000000
--- a/src/test/ui/parser/issue-17383.stderr
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0658]: custom discriminant values are not allowed in enums with tuple or struct variants
-  --> $DIR/issue-17383.rs:2:9
-   |
-LL |     A = 3,
-   |         ^ disallowed custom discriminant
-LL |
-LL |     B(usize)
-   |     -------- tuple variant defined here
-   |
-   = note: see issue #60553 <https://github.com/rust-lang/rust/issues/60553> for more information
-   = help: add `#![feature(arbitrary_enum_discriminant)]` to the crate attributes to enable
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/parser/tag-variant-disr-non-nullary.rs b/src/test/ui/parser/tag-variant-disr-non-nullary.rs
deleted file mode 100644
index a9cfdd549c7..00000000000
--- a/src/test/ui/parser/tag-variant-disr-non-nullary.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-enum Color {
-    Red = 0xff0000,
-    //~^ ERROR custom discriminant values are not allowed in enums with tuple or struct variants
-    Green = 0x00ff00,
-    Blue = 0x0000ff,
-    Black = 0x000000,
-    White = 0xffffff,
-    Other(usize),
-    Other2(usize, usize),
-}
-
-fn main() {}
diff --git a/src/test/ui/parser/tag-variant-disr-non-nullary.stderr b/src/test/ui/parser/tag-variant-disr-non-nullary.stderr
deleted file mode 100644
index 79f044a0675..00000000000
--- a/src/test/ui/parser/tag-variant-disr-non-nullary.stderr
+++ /dev/null
@@ -1,25 +0,0 @@
-error[E0658]: custom discriminant values are not allowed in enums with tuple or struct variants
-  --> $DIR/tag-variant-disr-non-nullary.rs:2:11
-   |
-LL |     Red = 0xff0000,
-   |           ^^^^^^^^ disallowed custom discriminant
-LL |
-LL |     Green = 0x00ff00,
-   |             ^^^^^^^^ disallowed custom discriminant
-LL |     Blue = 0x0000ff,
-   |            ^^^^^^^^ disallowed custom discriminant
-LL |     Black = 0x000000,
-   |             ^^^^^^^^ disallowed custom discriminant
-LL |     White = 0xffffff,
-   |             ^^^^^^^^ disallowed custom discriminant
-LL |     Other(usize),
-   |     ------------ tuple variant defined here
-LL |     Other2(usize, usize),
-   |     -------------------- tuple variant defined here
-   |
-   = note: see issue #60553 <https://github.com/rust-lang/rust/issues/60553> for more information
-   = help: add `#![feature(arbitrary_enum_discriminant)]` to the crate attributes to enable
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0658`.