Auto merge of #97456 - Bryysen:issue-97319-fix, r=compiler-errors
Improve error message for E0081 Closes #97319
This commit is contained in:
commit
abc7681a76
9 changed files with 174 additions and 76 deletions
|
|
@ -4,10 +4,11 @@
|
|||
// so force the repr.
|
||||
#[cfg_attr(not(target_pointer_width = "32"), repr(i32))]
|
||||
enum Eu64 {
|
||||
Au64 = 0, //~NOTE first use of `0`
|
||||
//~^ ERROR discriminant value `0` assigned more than once
|
||||
Au64 = 0,
|
||||
//~^NOTE first assignment of `0`
|
||||
Bu64 = 0x8000_0000_0000_0000
|
||||
//~^ ERROR discriminant value `0` already exists
|
||||
//~| NOTE enum already has `0` (overflowed from `9223372036854775808`)
|
||||
//~^NOTE second assignment of `0` (overflowed from `9223372036854775808`)
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
error[E0081]: discriminant value `0` already exists
|
||||
--> $DIR/enum-discrim-autosizing.rs:8:12
|
||||
error[E0081]: discriminant value `0` assigned more than once
|
||||
--> $DIR/enum-discrim-autosizing.rs:6:1
|
||||
|
|
||||
LL | Au64 = 0,
|
||||
| - first use of `0`
|
||||
LL | Bu64 = 0x8000_0000_0000_0000
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ enum already has `0` (overflowed from `9223372036854775808`)
|
||||
LL | / enum Eu64 {
|
||||
LL | |
|
||||
LL | | Au64 = 0,
|
||||
| | - first assignment of `0`
|
||||
LL | |
|
||||
LL | | Bu64 = 0x8000_0000_0000_0000
|
||||
| | --------------------- second assignment of `0` (overflowed from `9223372036854775808`)
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,30 @@
|
|||
enum Enum {
|
||||
//~^ ERROR discriminant value `3` assigned more than once
|
||||
P = 3,
|
||||
//~^ NOTE first use of `3`
|
||||
//~^ NOTE first assignment of `3`
|
||||
X = 3,
|
||||
//~^ ERROR discriminant value `3` already exists
|
||||
//~| NOTE enum already has `3`
|
||||
//~^ NOTE second assignment of `3`
|
||||
Y = 5
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
enum EnumOverflowRepr {
|
||||
//~^ ERROR discriminant value `1` assigned more than once
|
||||
P = 257,
|
||||
//~^ NOTE first use of `1` (overflowed from `257`)
|
||||
//~^ NOTE first assignment of `1` (overflowed from `257`)
|
||||
X = 513,
|
||||
//~^ ERROR discriminant value `1` already exists
|
||||
//~| NOTE enum already has `1` (overflowed from `513`)
|
||||
//~^ NOTE second assignment of `1` (overflowed from `513`)
|
||||
}
|
||||
|
||||
#[repr(i8)]
|
||||
enum NegDisEnum {
|
||||
//~^ ERROR discriminant value `-1` assigned more than once
|
||||
First = -1,
|
||||
//~^ NOTE first assignment of `-1`
|
||||
Second = -2,
|
||||
//~^ NOTE assigned discriminant for `Last` was incremented from this discriminant
|
||||
Last,
|
||||
//~^ NOTE second assignment of `-1`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,21 +1,49 @@
|
|||
error[E0081]: discriminant value `3` already exists
|
||||
--> $DIR/E0081.rs:4:9
|
||||
error[E0081]: discriminant value `3` assigned more than once
|
||||
--> $DIR/E0081.rs:1:1
|
||||
|
|
||||
LL | P = 3,
|
||||
| - first use of `3`
|
||||
LL |
|
||||
LL | X = 3,
|
||||
| ^ enum already has `3`
|
||||
LL | / enum Enum {
|
||||
LL | |
|
||||
LL | | P = 3,
|
||||
| | - first assignment of `3`
|
||||
LL | |
|
||||
LL | | X = 3,
|
||||
| | - second assignment of `3`
|
||||
LL | |
|
||||
LL | | Y = 5
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error[E0081]: discriminant value `1` already exists
|
||||
--> $DIR/E0081.rs:14:9
|
||||
error[E0081]: discriminant value `1` assigned more than once
|
||||
--> $DIR/E0081.rs:11:1
|
||||
|
|
||||
LL | P = 257,
|
||||
| --- first use of `1` (overflowed from `257`)
|
||||
LL |
|
||||
LL | X = 513,
|
||||
| ^^^ enum already has `1` (overflowed from `513`)
|
||||
LL | / enum EnumOverflowRepr {
|
||||
LL | |
|
||||
LL | | P = 257,
|
||||
| | --- first assignment of `1` (overflowed from `257`)
|
||||
LL | |
|
||||
LL | | X = 513,
|
||||
| | --- second assignment of `1` (overflowed from `513`)
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0081]: discriminant value `-1` assigned more than once
|
||||
--> $DIR/E0081.rs:20:1
|
||||
|
|
||||
LL | / enum NegDisEnum {
|
||||
LL | |
|
||||
LL | | First = -1,
|
||||
| | -- first assignment of `-1`
|
||||
LL | |
|
||||
LL | | Second = -2,
|
||||
| | ----------- assigned discriminant for `Last` was incremented from this discriminant
|
||||
LL | |
|
||||
LL | | Last,
|
||||
| | ---- second assignment of `-1`
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0081`.
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
const N: isize = 1;
|
||||
|
||||
enum Foo {
|
||||
//~^ ERROR discriminant value `1` assigned more than once
|
||||
//~| ERROR discriminant value `1` assigned more than once
|
||||
//~| ERROR discriminant value `1` assigned more than once
|
||||
A = 1,
|
||||
B = 1,
|
||||
//~^ ERROR discriminant value `1` already exists
|
||||
C = 0,
|
||||
D,
|
||||
//~^ ERROR discriminant value `1` already exists
|
||||
|
||||
E = N,
|
||||
//~^ ERROR discriminant value `1` already exists
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +1,53 @@
|
|||
error[E0081]: discriminant value `1` already exists
|
||||
--> $DIR/issue-15524.rs:5:9
|
||||
error[E0081]: discriminant value `1` assigned more than once
|
||||
--> $DIR/issue-15524.rs:3:1
|
||||
|
|
||||
LL | A = 1,
|
||||
| - first use of `1`
|
||||
LL | B = 1,
|
||||
| ^ enum already has `1`
|
||||
LL | / enum Foo {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | A = 1,
|
||||
| | - first assignment of `1`
|
||||
LL | | B = 1,
|
||||
| | - second assignment of `1`
|
||||
... |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error[E0081]: discriminant value `1` already exists
|
||||
--> $DIR/issue-15524.rs:8:5
|
||||
error[E0081]: discriminant value `1` assigned more than once
|
||||
--> $DIR/issue-15524.rs:3:1
|
||||
|
|
||||
LL | A = 1,
|
||||
| - first use of `1`
|
||||
...
|
||||
LL | D,
|
||||
| ^ enum already has `1`
|
||||
LL | / enum Foo {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | A = 1,
|
||||
| | - first assignment of `1`
|
||||
LL | | B = 1,
|
||||
LL | | C = 0,
|
||||
| | ----- assigned discriminant for `D` was incremented from this discriminant
|
||||
LL | | D,
|
||||
| | - second assignment of `1`
|
||||
... |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error[E0081]: discriminant value `1` already exists
|
||||
--> $DIR/issue-15524.rs:11:9
|
||||
error[E0081]: discriminant value `1` assigned more than once
|
||||
--> $DIR/issue-15524.rs:3:1
|
||||
|
|
||||
LL | A = 1,
|
||||
| - first use of `1`
|
||||
...
|
||||
LL | E = N,
|
||||
| ^ enum already has `1`
|
||||
LL | / enum Foo {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | A = 1,
|
||||
| | - first assignment of `1`
|
||||
... |
|
||||
LL | | E = N,
|
||||
| | - second assignment of `1`
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
// Black and White have the same discriminator value ...
|
||||
|
||||
enum Color {
|
||||
//~^ ERROR discriminant value `0` assigned more than once
|
||||
Red = 0xff0000,
|
||||
Green = 0x00ff00,
|
||||
Blue = 0x0000ff,
|
||||
Black = 0x000000,
|
||||
White = 0x000000, //~ ERROR discriminant value `0` already exists
|
||||
White = 0x000000,
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
error[E0081]: discriminant value `0` already exists
|
||||
--> $DIR/tag-variant-disr-dup.rs:8:13
|
||||
error[E0081]: discriminant value `0` assigned more than once
|
||||
--> $DIR/tag-variant-disr-dup.rs:3:1
|
||||
|
|
||||
LL | Black = 0x000000,
|
||||
| -------- first use of `0`
|
||||
LL | White = 0x000000,
|
||||
| ^^^^^^^^ enum already has `0`
|
||||
LL | / enum Color {
|
||||
LL | |
|
||||
LL | | Red = 0xff0000,
|
||||
LL | | Green = 0x00ff00,
|
||||
LL | | Blue = 0x0000ff,
|
||||
LL | | Black = 0x000000,
|
||||
| | -------- first assignment of `0`
|
||||
LL | | White = 0x000000,
|
||||
| | -------- second assignment of `0`
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue