]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0116.md
docs: revert removal of `E0729`
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0116.md
1 An inherent implementation was defined for a type outside the current crate.
2
3 Erroneous code example:
4
5 ```compile_fail,E0116
6 impl Vec<u8> { } // error
7 ```
8
9 You can only define an inherent implementation for a type in the same crate
10 where the type was defined. For example, an `impl` block as above is not allowed
11 since `Vec` is defined in the standard library.
12
13 To fix this problem, you can either:
14
15  - define a trait that has the desired associated functions/types/constants and
16    implement the trait for the type in question
17  - define a new type wrapping the type and define an implementation on the new
18    type
19
20 Note that using the `type` keyword does not work here because `type` only
21 introduces a type alias:
22
23 ```compile_fail,E0116
24 type Bytes = Vec<u8>;
25
26 impl Bytes { } // error, same as above
27 ```