@@ -1915,6 +1915,45 @@ More details can be found in [RFC 438].
1915
1915
[RFC 438]: https://github.com/rust-lang/rfcs/pull/438
1916
1916
"## ,
1917
1917
1918
+ E0182 : r##"
1919
+ You bound an associated type in an expression path which is not
1920
+ allowed.
1921
+
1922
+ Erroneous code example:
1923
+
1924
+ ```compile_fail,E0182
1925
+ trait Foo {
1926
+ type A;
1927
+ fn bar() -> isize;
1928
+ }
1929
+
1930
+ impl Foo for isize {
1931
+ type A = usize;
1932
+ fn bar() -> isize { 42 }
1933
+ }
1934
+
1935
+ // error: unexpected binding of associated item in expression path
1936
+ let x: isize = Foo::<A=usize>::bar();
1937
+ ```
1938
+
1939
+ To give a concrete type when using the Universal Function Call Syntax,
1940
+ use "Type as Trait". Example:
1941
+
1942
+ ```
1943
+ trait Foo {
1944
+ type A;
1945
+ fn bar() -> isize;
1946
+ }
1947
+
1948
+ impl Foo for isize {
1949
+ type A = usize;
1950
+ fn bar() -> isize { 42 }
1951
+ }
1952
+
1953
+ let x: isize = <isize as Foo>::bar(); // ok!
1954
+ ```
1955
+ "## ,
1956
+
1918
1957
E0184 : r##"
1919
1958
Explicitly implementing both Drop and Copy for a type is currently disallowed.
1920
1959
This feature can make some sense in theory, but the current implementation is
@@ -2752,6 +2791,30 @@ fn main() {
2752
2791
```
2753
2792
"## ,
2754
2793
2794
+ E0230 : r##"
2795
+ The trait has more type parameters specified than appear in its definition.
2796
+
2797
+ Erroneous example code:
2798
+
2799
+ ```compile_fail,E0230
2800
+ #![feature(on_unimplemented)]
2801
+ #[rustc_on_unimplemented = "Trait error on `{Self}` with `<{A},{B},{C}>`"]
2802
+ // error: there is no type parameter C on trait TraitWithThreeParams
2803
+ trait TraitWithThreeParams<A,B>
2804
+ {}
2805
+ ```
2806
+
2807
+ Include the correct number of type parameters and the compilation should
2808
+ proceed:
2809
+
2810
+ ```
2811
+ #![feature(on_unimplemented)]
2812
+ #[rustc_on_unimplemented = "Trait error on `{Self}` with `<{A},{B},{C}>`"]
2813
+ trait TraitWithThreeParams<A,B,C> // ok!
2814
+ {}
2815
+ ```
2816
+ "## ,
2817
+
2755
2818
E0232 : r##"
2756
2819
The attribute must have a value. Erroneous code example:
2757
2820
@@ -3587,6 +3650,44 @@ fn together_we_will_rule_the_galaxy(son: &A<i32>) {} // Ok!
3587
3650
```
3588
3651
"## ,
3589
3652
3653
+ E0399 : r##"
3654
+ You implemented a trait, overriding one or more of its associated types but did
3655
+ not reimplement its default methods.
3656
+
3657
+ Example of erroneous code:
3658
+
3659
+ ```compile_fail,E0399
3660
+ #![feature(associated_type_defaults)]
3661
+
3662
+ pub trait Foo {
3663
+ type Assoc = u8;
3664
+ fn bar(&self) {}
3665
+ }
3666
+
3667
+ impl Foo for i32 {
3668
+ // error - the following trait items need to be reimplemented as
3669
+ // `Assoc` was overridden: `bar`
3670
+ type Assoc = i32;
3671
+ }
3672
+ ```
3673
+
3674
+ To fix this, add an implementation for each default method from the trait:
3675
+
3676
+ ```
3677
+ #![feature(associated_type_defaults)]
3678
+
3679
+ pub trait Foo {
3680
+ type Assoc = u8;
3681
+ fn bar(&self) {}
3682
+ }
3683
+
3684
+ impl Foo for i32 {
3685
+ type Assoc = i32;
3686
+ fn bar(&self) {} // ok!
3687
+ }
3688
+ ```
3689
+ "## ,
3690
+
3590
3691
E0439 : r##"
3591
3692
The length of the platform-intrinsic function `simd_shuffle`
3592
3693
wasn't specified. Erroneous code example:
@@ -4074,7 +4175,6 @@ register_diagnostics! {
4074
4175
// E0168,
4075
4176
// E0173, // manual implementations of unboxed closure traits are experimental
4076
4177
// E0174,
4077
- E0182 ,
4078
4178
E0183 ,
4079
4179
// E0187, // can't infer the kind of the closure
4080
4180
// E0188, // can not cast an immutable reference to a mutable pointer
@@ -4098,7 +4198,6 @@ register_diagnostics! {
4098
4198
E0226 , // only a single explicit lifetime bound is permitted
4099
4199
E0227 , // ambiguous lifetime bound, explicit lifetime bound required
4100
4200
E0228 , // explicit lifetime bound required
4101
- E0230 , // there is no type parameter on trait
4102
4201
E0231 , // only named substitution parameters are allowed
4103
4202
// E0233,
4104
4203
// E0234,
@@ -4120,8 +4219,6 @@ register_diagnostics! {
4120
4219
// E0372, // coherence not object safe
4121
4220
E0377 , // the trait `CoerceUnsized` may only be implemented for a coercion
4122
4221
// between structures with the same definition
4123
- E0399 , // trait items need to be implemented because the associated
4124
- // type `{}` was overridden
4125
4222
E0436 , // functional record update requires a struct
4126
4223
E0521 , // redundant default implementations of trait
4127
4224
E0533 , // `{}` does not name a unit variant, unit struct or a constant
0 commit comments