]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0390.md
Auto merge of #79780 - camelid:use-summary_opts, r=GuillaumeGomez
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0390.md
1 A method or constant was implemented on a primitive type.
2
3 Erroneous code example:
4
5 ```compile_fail,E0390
6 struct Foo {
7     x: i32
8 }
9
10 impl *mut Foo {}
11 // error: only a single inherent implementation marked with
12 //        `#[lang = "mut_ptr"]` is allowed for the `*mut T` primitive
13 ```
14
15 This isn't allowed, but using a trait to implement a method or constant
16 is a good solution.
17 Example:
18
19 ```
20 struct Foo {
21     x: i32
22 }
23
24 trait Bar {
25     fn bar();
26 }
27
28 impl Bar for *mut Foo {
29     fn bar() {} // ok!
30 }
31 ```