]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0390.md
Rollup merge of #62514 - stephaneyfx:box-ffi, r=nikomatsakis
[rust.git] / src / librustc_error_codes / error_codes / E0390.md
1 You tried to implement methods for a primitive type. Erroneous code example:
2
3 ```compile_fail,E0390
4 struct Foo {
5     x: i32
6 }
7
8 impl *mut Foo {}
9 // error: only a single inherent implementation marked with
10 //        `#[lang = "mut_ptr"]` is allowed for the `*mut T` primitive
11 ```
12
13 This isn't allowed, but using a trait to implement a method is a good solution.
14 Example:
15
16 ```
17 struct Foo {
18     x: i32
19 }
20
21 trait Bar {
22     fn bar();
23 }
24
25 impl Bar for *mut Foo {
26     fn bar() {} // ok!
27 }
28 ```