Skip to content

Commit acafe3b

Browse files
Add E0370 error explanation
1 parent 805e4e6 commit acafe3b

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

src/librustc_typeck/diagnostics.rs

+32-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct Foo {
8484
8585
fn main(){
8686
let x = Foo { a:1, b:2 };
87-
87+
8888
let Foo { a: x, a: y } = x;
8989
// error: field `a` bound multiple times in the pattern
9090
}
@@ -102,7 +102,7 @@ struct Foo {
102102
103103
fn main(){
104104
let x = Foo { a:1, b:2 };
105-
105+
106106
let Foo { a: x, b: y } = x; // ok!
107107
}
108108
```
@@ -2820,6 +2820,36 @@ It is also possible to overload most operators for your own type by
28202820
implementing traits from `std::ops`.
28212821
"##,
28222822

2823+
E0370: r##"
2824+
The maximum value of an enum was reached, so it cannot be automatically
2825+
set in the next enum value. Erroneous code example:
2826+
2827+
```
2828+
enum Foo {
2829+
X = 0x7fffffffffffffff,
2830+
Y // error: enum discriminant overflowed on value after
2831+
// 9223372036854775807: i64; set explicitly via
2832+
// Y = -9223372036854775808 if that is desired outcome
2833+
}
2834+
```
2835+
2836+
To fix this, please set manually the next enum value or put the enum variant
2837+
with the maximum value at the end of the enum. Examples:
2838+
2839+
```
2840+
enum Foo {
2841+
X = 0x7fffffffffffffff,
2842+
Y = 0, // ok!
2843+
}
2844+
2845+
// or:
2846+
enum Foo {
2847+
Y = 0, // ok!
2848+
X = 0x7fffffffffffffff,
2849+
}
2850+
```
2851+
"##,
2852+
28232853
E0371: r##"
28242854
When `Trait2` is a subtrait of `Trait1` (for example, when `Trait2` has a
28252855
definition like `trait Trait2: Trait1 { ... }`), it is not allowed to implement
@@ -3037,7 +3067,6 @@ register_diagnostics! {
30373067
E0321, // extended coherence rules for defaulted traits violated
30383068
E0328, // cannot implement Unsize explicitly
30393069
E0329, // associated const depends on type parameter or Self.
3040-
E0370, // discriminant overflow
30413070
E0374, // the trait `CoerceUnsized` may only be implemented for a coercion
30423071
// between structures with one field being coerced, none found
30433072
E0375, // the trait `CoerceUnsized` may only be implemented for a coercion

0 commit comments

Comments
 (0)