Skip to content

Commit 9365586

Browse files
author
Ryan Senior
committed
Add an error explaination for E0399
1 parent e7d01cf commit 9365586

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3630,6 +3630,44 @@ fn together_we_will_rule_the_galaxy(son: &A<i32>) {} // Ok!
36303630
```
36313631
"##,
36323632

3633+
E0399: r##"
3634+
You implemented a trait, overriding one or more of its associated types but did
3635+
not reimplement its default methods.
3636+
3637+
Example of erroneous code:
3638+
3639+
```compile_fail,E0399
3640+
#![feature(associated_type_defaults)]
3641+
3642+
pub trait Foo {
3643+
type Assoc = u8;
3644+
fn bar(&self) {}
3645+
}
3646+
3647+
impl Foo for i32 {
3648+
// error - the following trait items need to be reimplemented as
3649+
// `Assoc` was overridden: `bar`
3650+
type Assoc = i32;
3651+
}
3652+
```
3653+
3654+
To fix this, add an implementation for each default method from the trait:
3655+
3656+
```
3657+
#![feature(associated_type_defaults)]
3658+
3659+
pub trait Foo {
3660+
type Assoc = u8;
3661+
fn bar(&self) {}
3662+
}
3663+
3664+
impl Foo for i32 {
3665+
type Assoc = i32;
3666+
fn bar(&self) {} // ok!
3667+
}
3668+
```
3669+
"##,
3670+
36333671
E0439: r##"
36343672
The length of the platform-intrinsic function `simd_shuffle`
36353673
wasn't specified. Erroneous code example:
@@ -4161,8 +4199,6 @@ register_diagnostics! {
41614199
// E0372, // coherence not object safe
41624200
E0377, // the trait `CoerceUnsized` may only be implemented for a coercion
41634201
// between structures with the same definition
4164-
E0399, // trait items need to be implemented because the associated
4165-
// type `{}` was overridden
41664202
E0436, // functional record update requires a struct
41674203
E0521, // redundant default implementations of trait
41684204
E0533, // `{}` does not name a unit variant, unit struct or a constant

0 commit comments

Comments
 (0)