blob: 14e954722a2501c34ef182a978eb35f78b8346e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
The maximum value of an enum was reached, so it cannot be automatically
set in the next enum value.
Erroneous code example:
```compile_fail,E0370
#[repr(i64)]
enum Foo {
X = 0x7fffffffffffffff,
Y, // error: enum discriminant overflowed on value after
// 9223372036854775807: i64; set explicitly via
// Y = -9223372036854775808 if that is desired outcome
}
```
To fix this, please set manually the next enum value or put the enum variant
with the maximum value at the end of the enum. Examples:
```
#[repr(i64)]
enum Foo {
X = 0x7fffffffffffffff,
Y = 0, // ok!
}
```
Or:
```
#[repr(i64)]
enum Foo {
Y = 0, // ok!
X = 0x7fffffffffffffff,
}
```
|