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:
parent
f688ba6089
commit
3cbf5864a6
6 changed files with 63 additions and 26 deletions
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue