]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0371.md
Rollup merge of #62514 - stephaneyfx:box-ffi, r=nikomatsakis
[rust.git] / src / librustc_error_codes / error_codes / E0371.md
1 When `Trait2` is a subtrait of `Trait1` (for example, when `Trait2` has a
2 definition like `trait Trait2: Trait1 { ... }`), it is not allowed to implement
3 `Trait1` for `Trait2`. This is because `Trait2` already implements `Trait1` by
4 definition, so it is not useful to do this.
5
6 Example:
7
8 ```compile_fail,E0371
9 trait Foo { fn foo(&self) { } }
10 trait Bar: Foo { }
11 trait Baz: Bar { }
12
13 impl Bar for Baz { } // error, `Baz` implements `Bar` by definition
14 impl Foo for Baz { } // error, `Baz` implements `Bar` which implements `Foo`
15 impl Baz for Baz { } // error, `Baz` (trivially) implements `Baz`
16 impl Baz for Bar { } // Note: This is OK
17 ```