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