Skip to content

Commit 962b61f

Browse files
Improve error explanation and example in E0390
1 parent 633fe44 commit 962b61f

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2791,11 +2791,21 @@ impl *mut Foo {}
27912791
// `#[lang = "mut_ptr"]` is allowed for the `*mut T` primitive
27922792
```
27932793
2794-
This isn't allowed, perhaps you might get the desired effects by wrapping the
2795-
raw pointer in a struct. Example:
2794+
This isn't allowed, but using a trait to implement a method is a good solution.
2795+
Example:
27962796
27972797
```
2798-
struct FooPtr(pub *mut Foo);
2798+
struct Foo {
2799+
x: i32
2800+
}
2801+
2802+
trait Bar {
2803+
fn bar();
2804+
}
2805+
2806+
impl Bar for *mut Foo {
2807+
fn bar() {} // ok!
2808+
}
27992809
```
28002810
"##,
28012811

0 commit comments

Comments
 (0)