tweak discriminant on non-nullary enum diagnostic

Adds notes pointing at the non-nullary variants, and uses "custom
discriminant" language to be consistent with the Reference.
This commit is contained in:
Andy Russell 2019-05-22 16:56:51 -04:00
parent f688ba6089
commit 3cbf5864a6
No known key found for this signature in database
GPG key ID: BE2221033EDBC374
6 changed files with 63 additions and 26 deletions

View file

@ -1,6 +1,6 @@
enum X {
A = 3,
//~^ ERROR discriminator values can only be used with a field-less enum
//~^ ERROR custom discriminant values are not allowed in enums with fields
B(usize)
}

View file

@ -1,8 +1,11 @@
error: discriminator values can only be used with a field-less enum
error: custom discriminant values are not allowed in enums with fields
--> $DIR/issue-17383.rs:2:9
|
LL | A = 3,
| ^ only valid in field-less enums
| ^ invalid custom discriminant
LL |
LL | B(usize)
| -------- variant with a field defined here
error: aborting due to previous error

View file

@ -1,11 +1,12 @@
enum Color {
Red = 0xff0000,
//~^ ERROR discriminator values can only be used with a field-less enum
//~^ ERROR custom discriminant values are not allowed in enums with fields
Green = 0x00ff00,
Blue = 0x0000ff,
Black = 0x000000,
White = 0xffffff,
Other(usize),
Other2(usize, usize),
}
fn main() {}

View file

@ -1,17 +1,21 @@
error: discriminator values can only be used with a field-less enum
error: custom discriminant values are not allowed in enums with fields
--> $DIR/tag-variant-disr-non-nullary.rs:2:11
|
LL | Red = 0xff0000,
| ^^^^^^^^ only valid in field-less enums
| ^^^^^^^^ invalid custom discriminant
LL |
LL | Green = 0x00ff00,
| ^^^^^^^^ only valid in field-less enums
| ^^^^^^^^ invalid custom discriminant
LL | Blue = 0x0000ff,
| ^^^^^^^^ only valid in field-less enums
| ^^^^^^^^ invalid custom discriminant
LL | Black = 0x000000,
| ^^^^^^^^ only valid in field-less enums
| ^^^^^^^^ invalid custom discriminant
LL | White = 0xffffff,
| ^^^^^^^^ only valid in field-less enums
| ^^^^^^^^ invalid custom discriminant
LL | Other(usize),
| ------------ variant with a field defined here
LL | Other2(usize, usize),
| -------------------- variant with fields defined here
error: aborting due to previous error