Show discriminant before overflow in diagnostic.
This commit is contained in:
parent
8b50cc9a2c
commit
4c0ff4db80
5 changed files with 52 additions and 8 deletions
|
|
@ -4,8 +4,10 @@
|
|||
// so force the repr.
|
||||
#[cfg_attr(not(target_pointer_width = "32"), repr(i32))]
|
||||
enum Eu64 {
|
||||
Au64 = 0,
|
||||
Bu64 = 0x8000_0000_0000_0000 //~ERROR already exists
|
||||
Au64 = 0, //~NOTE first use of `0`
|
||||
Bu64 = 0x8000_0000_0000_0000
|
||||
//~^ ERROR discriminant value `0` already exists
|
||||
//~| NOTE enum already has `0` (overflowed from `9223372036854775808`)
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error[E0081]: discriminant value `0` already exists
|
|||
LL | Au64 = 0,
|
||||
| - first use of `0`
|
||||
LL | Bu64 = 0x8000_0000_0000_0000
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ enum already has `0`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ enum already has `0` (overflowed from `9223372036854775808`)
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,20 @@
|
|||
enum Enum {
|
||||
P = 3,
|
||||
//~^ NOTE first use of `3`
|
||||
X = 3,
|
||||
//~^ ERROR discriminant value `3` already exists
|
||||
//~| NOTE enum already has `3`
|
||||
Y = 5
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
enum EnumOverflowRepr {
|
||||
P = 257,
|
||||
//~^ NOTE first use of `1` (overflowed from `257`)
|
||||
X = 513,
|
||||
//~^ ERROR discriminant value `1` already exists
|
||||
//~| NOTE enum already has `1` (overflowed from `513`)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,21 @@
|
|||
error[E0081]: discriminant value `3` already exists
|
||||
--> $DIR/E0081.rs:3:9
|
||||
--> $DIR/E0081.rs:4:9
|
||||
|
|
||||
LL | P = 3,
|
||||
| - first use of `3`
|
||||
LL |
|
||||
LL | X = 3,
|
||||
| ^ enum already has `3`
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0081]: discriminant value `1` already exists
|
||||
--> $DIR/E0081.rs:14:9
|
||||
|
|
||||
LL | P = 257,
|
||||
| --- first use of `1` (overflowed from `257`)
|
||||
LL |
|
||||
LL | X = 513,
|
||||
| ^^^ enum already has `1` (overflowed from `513`)
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0081`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue