-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
6 changed files
with
63 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|