]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0399.md
Rollup merge of #62514 - stephaneyfx:box-ffi, r=nikomatsakis
[rust.git] / src / librustc_error_codes / error_codes / E0399.md
1 You implemented a trait, overriding one or more of its associated types but did
2 not reimplement its default methods.
3
4 Example of erroneous code:
5
6 ```compile_fail,E0399
7 #![feature(associated_type_defaults)]
8
9 pub trait Foo {
10     type Assoc = u8;
11     fn bar(&self) {}
12 }
13
14 impl Foo for i32 {
15     // error - the following trait items need to be reimplemented as
16     //         `Assoc` was overridden: `bar`
17     type Assoc = i32;
18 }
19 ```
20
21 To fix this, add an implementation for each default method from the trait:
22
23 ```
24 #![feature(associated_type_defaults)]
25
26 pub trait Foo {
27     type Assoc = u8;
28     fn bar(&self) {}
29 }
30
31 impl Foo for i32 {
32     type Assoc = i32;
33     fn bar(&self) {} // ok!
34 }
35 ```