Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tweak incorrect discriminator value variant error
- Loading branch information
Showing
5 changed files
with
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
enum X { | ||
A = | ||
b'a' //~ ERROR discriminator values can only be used with a field-less enum | ||
, | ||
B(isize) | ||
A = 3, | ||
//~^ ERROR discriminator values can only be used with a field-less enum | ||
B(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,8 +1,8 @@ | ||
error: discriminator values can only be used with a field-less enum | ||
--> $DIR/issue-17383.rs:3:9 | ||
--> $DIR/issue-17383.rs:2:9 | ||
| | ||
LL | b'a' //~ ERROR discriminator values can only be used with a field-less enum | ||
| ^^^^ | ||
LL | A = 3, | ||
| ^ only valid in field-less enums | ||
|
||
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,12 +1,14 @@ | ||
//error-pattern: discriminator values can only be used with a field-less enum | ||
|
||
enum color { | ||
red = 0xff0000, | ||
green = 0x00ff00, | ||
blue = 0x0000ff, | ||
black = 0x000000, | ||
white = 0xffffff, | ||
other (str), | ||
enum Color { | ||
Red = 0xff0000, | ||
//~^ ERROR discriminator values can only be used with a field-less enum | ||
Green = 0x00ff00, | ||
Blue = 0x0000ff, | ||
Black = 0x000000, | ||
White = 0xffffff, | ||
Other (str), | ||
//~^ ERROR the size for values of type | ||
// the above is kept in order to verify that we get beyond parse errors | ||
} | ||
|
||
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,8 +1,28 @@ | ||
error: discriminator values can only be used with a field-less enum | ||
--> $DIR/tag-variant-disr-non-nullary.rs:8:13 | ||
--> $DIR/tag-variant-disr-non-nullary.rs:3:11 | ||
| | ||
LL | white = 0xffffff, | ||
| ^^^^^^^^ | ||
LL | Red = 0xff0000, | ||
| ^^^^^^^^ only valid in field-less enums | ||
LL | //~^ ERROR discriminator values can only be used with a field-less enum | ||
LL | Green = 0x00ff00, | ||
| ^^^^^^^^ only valid in field-less enums | ||
LL | Blue = 0x0000ff, | ||
| ^^^^^^^^ only valid in field-less enums | ||
LL | Black = 0x000000, | ||
| ^^^^^^^^ only valid in field-less enums | ||
LL | White = 0xffffff, | ||
| ^^^^^^^^ only valid in field-less enums | ||
|
||
error: aborting due to previous error | ||
error[E0277]: the size for values of type `str` cannot be known at compilation time | ||
--> $DIR/tag-variant-disr-non-nullary.rs:9:12 | ||
| | ||
LL | Other (str), | ||
| ^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `std::marker::Sized` is not implemented for `str` | ||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> | ||
= note: no field of an enum variant may have a dynamically sized type | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |