@@ -73,10 +73,39 @@ the enum.
73
73
"## ,
74
74
75
75
E0025 : r##"
76
- Each field of a struct can only be bound once in a pattern. Each occurrence of a
77
- field name binds the value of that field, so to fix this error you will have to
78
- remove or alter the duplicate uses of the field name. Perhaps you misspelt
79
- another field name?
76
+ Each field of a struct can only be bound once in a pattern. Erroneous code
77
+ example:
78
+
79
+ ```
80
+ struct Foo {
81
+ a: u8,
82
+ b: u8,
83
+ }
84
+
85
+ fn main(){
86
+ let x = Foo { a:1, b:2 };
87
+
88
+ let Foo { a: x, a: y } = x;
89
+ // error: field `a` bound multiple times in the pattern
90
+ }
91
+ ```
92
+
93
+ Each occurrence of a field name binds the value of that field, so to fix this
94
+ error you will have to remove or alter the duplicate uses of the field name.
95
+ Perhaps you misspelled another field name? Example:
96
+
97
+ ```
98
+ struct Foo {
99
+ a: u8,
100
+ b: u8,
101
+ }
102
+
103
+ fn main(){
104
+ let x = Foo { a:1, b:2 };
105
+
106
+ let Foo { a: x, b: y } = x; // ok!
107
+ }
108
+ ```
80
109
"## ,
81
110
82
111
E0026 : r##"
@@ -401,10 +430,35 @@ extern "C" {
401
430
"## ,
402
431
403
432
E0046 : r##"
433
+ Items are missing in a trait implementation. Erroneous code example:
434
+
435
+ ```
436
+ trait Foo {
437
+ fn foo();
438
+ }
439
+
440
+ struct Bar;
441
+
442
+ impl Foo for Bar {}
443
+ // error: not all trait items implemented, missing: `foo`
444
+ ```
445
+
404
446
When trying to make some type implement a trait `Foo`, you must, at minimum,
405
447
provide implementations for all of `Foo`'s required methods (meaning the
406
448
methods that do not have default implementations), as well as any required
407
- trait items like associated types or constants.
449
+ trait items like associated types or constants. Example:
450
+
451
+ ```
452
+ trait Foo {
453
+ fn foo();
454
+ }
455
+
456
+ struct Bar;
457
+
458
+ impl Foo for Bar {
459
+ fn foo() {} // ok!
460
+ }
461
+ ```
408
462
"## ,
409
463
410
464
E0049 : r##"
@@ -615,14 +669,62 @@ variadic functions (except for its C-FFI).
615
669
616
670
E0062 : r##"
617
671
This error indicates that during an attempt to build a struct or struct-like
618
- enum variant, one of the fields was specified more than once. Each field should
619
- be specified exactly one time.
672
+ enum variant, one of the fields was specified more than once. Erroneous code
673
+ example:
674
+
675
+ ```
676
+ struct Foo {
677
+ x: i32
678
+ }
679
+
680
+ fn main() {
681
+ let x = Foo {
682
+ x: 0,
683
+ x: 0, // error: field `x` specified more than once
684
+ };
685
+ }
686
+ ```
687
+
688
+ Each field should be specified exactly one time. Example:
689
+
690
+ ```
691
+ struct Foo {
692
+ x: i32
693
+ }
694
+
695
+ fn main() {
696
+ let x = Foo { x: 0 }; // ok!
697
+ }
698
+ ```
620
699
"## ,
621
700
622
701
E0063 : r##"
623
702
This error indicates that during an attempt to build a struct or struct-like
624
- enum variant, one of the fields was not provided. Each field should be
625
- specified exactly once.
703
+ enum variant, one of the fields was not provided. Erroneous code example:
704
+
705
+ ```
706
+ struct Foo {
707
+ x: i32,
708
+ y: i32
709
+ }
710
+
711
+ fn main() {
712
+ let x = Foo { x: 0 }; // error: missing field: `y`
713
+ }
714
+ ```
715
+
716
+ Each field should be specified exactly once. Example:
717
+
718
+ ```
719
+ struct Foo {
720
+ x: i32,
721
+ y: i32
722
+ }
723
+
724
+ fn main() {
725
+ let x = Foo { x: 0, y: 0 }; // ok!
726
+ }
727
+ ```
626
728
"## ,
627
729
628
730
E0066 : r##"
@@ -1025,7 +1127,7 @@ fn main() {
1025
1127
}
1026
1128
```
1027
1129
1028
- The number of supplied parameters much exactly match the number of defined type
1130
+ The number of supplied parameters must exactly match the number of defined type
1029
1131
parameters.
1030
1132
"## ,
1031
1133
@@ -1620,14 +1722,20 @@ extern {
1620
1722
E0131 : r##"
1621
1723
It is not possible to define `main` with type parameters, or even with function
1622
1724
parameters. When `main` is present, it must take no arguments and return `()`.
1725
+ Erroneous code example:
1726
+
1727
+ ```
1728
+ fn main<T>() { // error: main function is not allowed to have type parameters
1729
+ }
1730
+ ```
1623
1731
"## ,
1624
1732
1625
1733
E0132 : r##"
1626
1734
It is not possible to declare type parameters on a function that has the `start`
1627
1735
attribute. Such a function must have the following type signature:
1628
1736
1629
1737
```
1630
- fn(isize, *const *const u8) -> isize
1738
+ fn(isize, *const *const u8) -> isize;
1631
1739
```
1632
1740
"## ,
1633
1741
@@ -1779,7 +1887,7 @@ rfcs/blob/master/text/0019-opt-in-builtin-traits.md).
1779
1887
1780
1888
E0193 : r##"
1781
1889
`where` clauses must use generic type parameters: it does not make sense to use
1782
- them otherwise. An example causing this error:
1890
+ them otherwise. An example causing this error:
1783
1891
1784
1892
```
1785
1893
trait Foo {
@@ -1881,7 +1989,6 @@ unsafe impl Foo { }
1881
1989
// converting it to this will fix it
1882
1990
impl Foo { }
1883
1991
```
1884
-
1885
1992
"## ,
1886
1993
1887
1994
E0198 : r##"
@@ -1898,7 +2005,6 @@ unsafe impl !Clone for Foo { }
1898
2005
// this will compile
1899
2006
impl !Clone for Foo { }
1900
2007
```
1901
-
1902
2008
"## ,
1903
2009
1904
2010
E0199 : r##"
@@ -1916,7 +2022,6 @@ unsafe impl Bar for Foo { }
1916
2022
// this will compile
1917
2023
impl Bar for Foo { }
1918
2024
```
1919
-
1920
2025
"## ,
1921
2026
1922
2027
E0200 : r##"
@@ -1934,7 +2039,6 @@ impl Bar for Foo { }
1934
2039
// this will compile
1935
2040
unsafe impl Bar for Foo { }
1936
2041
```
1937
-
1938
2042
"## ,
1939
2043
1940
2044
E0201 : r##"
@@ -2717,6 +2821,36 @@ It is also possible to overload most operators for your own type by
2717
2821
implementing traits from `std::ops`.
2718
2822
"## ,
2719
2823
2824
+ E0370 : r##"
2825
+ The maximum value of an enum was reached, so it cannot be automatically
2826
+ set in the next enum value. Erroneous code example:
2827
+
2828
+ ```
2829
+ enum Foo {
2830
+ X = 0x7fffffffffffffff,
2831
+ Y // error: enum discriminant overflowed on value after
2832
+ // 9223372036854775807: i64; set explicitly via
2833
+ // Y = -9223372036854775808 if that is desired outcome
2834
+ }
2835
+ ```
2836
+
2837
+ To fix this, please set manually the next enum value or put the enum variant
2838
+ with the maximum value at the end of the enum. Examples:
2839
+
2840
+ ```
2841
+ enum Foo {
2842
+ X = 0x7fffffffffffffff,
2843
+ Y = 0, // ok!
2844
+ }
2845
+
2846
+ // or:
2847
+ enum Foo {
2848
+ Y = 0, // ok!
2849
+ X = 0x7fffffffffffffff,
2850
+ }
2851
+ ```
2852
+ "## ,
2853
+
2720
2854
E0371 : r##"
2721
2855
When `Trait2` is a subtrait of `Trait1` (for example, when `Trait2` has a
2722
2856
definition like `trait Trait2: Trait1 { ... }`), it is not allowed to implement
@@ -2869,44 +3003,44 @@ https://doc.rust-lang.org/std/marker/struct.PhantomData.html
2869
3003
}
2870
3004
2871
3005
register_diagnostics ! {
2872
- E0068 ,
2873
- E0085 ,
2874
- E0086 ,
3006
+ // E0068,
3007
+ // E0085,
3008
+ // E0086,
2875
3009
E0090 ,
2876
3010
E0103 , // @GuillaumeGomez: I was unable to get this error, try your best!
2877
3011
E0104 ,
2878
3012
E0118 ,
2879
3013
E0122 ,
2880
- E0123 ,
2881
- E0127 ,
2882
- E0129 ,
2883
- E0141 ,
3014
+ // E0123,
3015
+ // E0127,
3016
+ // E0129,
3017
+ // E0141,
2884
3018
// E0159, // use of trait `{}` as struct constructor
2885
3019
E0163 ,
2886
3020
E0164 ,
2887
3021
E0167 ,
2888
3022
// E0168,
2889
- E0173 , // manual implementations of unboxed closure traits are experimental
3023
+ // E0173, // manual implementations of unboxed closure traits are experimental
2890
3024
E0174 , // explicit use of unboxed closure methods are experimental
2891
3025
E0182 ,
2892
3026
E0183 ,
2893
- E0187 , // can't infer the kind of the closure
2894
- E0188 , // can not cast a immutable reference to a mutable pointer
2895
- E0189 , // deprecated: can only cast a boxed pointer to a boxed object
2896
- E0190 , // deprecated: can only cast a &-pointer to an &-object
3027
+ // E0187, // can't infer the kind of the closure
3028
+ // E0188, // can not cast a immutable reference to a mutable pointer
3029
+ // E0189, // deprecated: can only cast a boxed pointer to a boxed object
3030
+ // E0190, // deprecated: can only cast a &-pointer to an &-object
2897
3031
E0196 , // cannot determine a type for this closure
2898
3032
E0203 , // type parameter has more than one relaxed default bound,
2899
3033
// and only one is supported
2900
3034
E0208 ,
2901
- E0209 , // builtin traits can only be implemented on structs or enums
3035
+ // E0209, // builtin traits can only be implemented on structs or enums
2902
3036
E0212 , // cannot extract an associated type from a higher-ranked trait bound
2903
- E0213 , // associated types are not accepted in this context
3037
+ // E0213, // associated types are not accepted in this context
2904
3038
E0214 , // parenthesized parameters may only be used with a trait
2905
3039
// E0215, // angle-bracket notation is not stable with `Fn`
2906
3040
// E0216, // parenthetical notation is only stable with `Fn`
2907
- E0217 , // ambiguous associated type, defined in multiple supertraits
2908
- E0218 , // no associated type defined
2909
- E0219 , // associated type defined in higher-ranked supertrait
3041
+ // E0217, // ambiguous associated type, defined in multiple supertraits
3042
+ // E0218, // no associated type defined
3043
+ // E0219, // associated type defined in higher-ranked supertrait
2910
3044
// E0222, // Error code E0045 (variadic function must have C calling
2911
3045
// convention) duplicate
2912
3046
E0224 , // at least one non-builtin train is required for an object type
@@ -2916,25 +3050,24 @@ register_diagnostics! {
2916
3050
E0229 , // associated type bindings are not allowed here
2917
3051
E0230 , // there is no type parameter on trait
2918
3052
E0231 , // only named substitution parameters are allowed
2919
- E0233 ,
2920
- E0234 ,
3053
+ // E0233,
3054
+ // E0234,
2921
3055
// E0235, // structure constructor specifies a structure of type but
2922
3056
E0236 , // no lang item for range syntax
2923
3057
E0237 , // no lang item for range syntax
2924
3058
E0238 , // parenthesized parameters may only be used with a trait
2925
- E0239 , // `next` method of `Iterator` trait has unexpected type
2926
- E0240 ,
2927
- E0241 ,
3059
+ // E0239, // `next` method of `Iterator` trait has unexpected type
3060
+ // E0240,
3061
+ // E0241,
2928
3062
E0242 , // internal error looking up a definition
2929
3063
E0245 , // not a trait
2930
- E0246 , // invalid recursive type
3064
+ // E0246, // invalid recursive type
2931
3065
E0247 , // found module name used as a type
2932
- E0319 , // trait impls for defaulted traits allowed just for structs/enums
3066
+ // E0319, // trait impls for defaulted traits allowed just for structs/enums
2933
3067
E0320 , // recursive overflow during dropck
2934
3068
E0321 , // extended coherence rules for defaulted traits violated
2935
3069
E0328 , // cannot implement Unsize explicitly
2936
3070
E0329 , // associated const depends on type parameter or Self.
2937
- E0370 , // discriminant overflow
2938
3071
E0374 , // the trait `CoerceUnsized` may only be implemented for a coercion
2939
3072
// between structures with one field being coerced, none found
2940
3073
E0375 , // the trait `CoerceUnsized` may only be implemented for a coercion
0 commit comments