]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0370.md
Rollup merge of #107190 - fmease:fix-81698, r=compiler-errors
[rust.git] / compiler / rustc_error_codes / src / 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.
3
4 Erroneous code example:
5
6 ```compile_fail,E0370
7 #[repr(i64)]
8 enum Foo {
9     X = 0x7fffffffffffffff,
10     Y, // error: enum discriminant overflowed on value after
11        //        9223372036854775807: i64; set explicitly via
12        //        Y = -9223372036854775808 if that is desired outcome
13 }
14 ```
15
16 To fix this, please set manually the next enum value or put the enum variant
17 with the maximum value at the end of the enum. Examples:
18
19 ```
20 #[repr(i64)]
21 enum Foo {
22     X = 0x7fffffffffffffff,
23     Y = 0, // ok!
24 }
25 ```
26
27 Or:
28
29 ```
30 #[repr(i64)]
31 enum Foo {
32     Y = 0, // ok!
33     X = 0x7fffffffffffffff,
34 }
35 ```