Skip to content

Commit ac28aba

Browse files
committed
added how to fix the problem block
1 parent 437c66c commit ac28aba

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/librustc_typeck/diagnostics.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -3091,7 +3091,7 @@ E0328: r##"
30913091
The Unsize trait should not be implemented directly. All implementations of
30923092
Unsize are provided automatically by the compiler.
30933093
3094-
Here's an example of this error:
3094+
Erroneous code example:
30953095
30963096
```compile_fail,E0328
30973097
#![feature(unsize)]
@@ -3108,6 +3108,19 @@ conversion from a sized to an unsized type with the [DST coercion system]
31083108
(https://github.com/rust-lang/rfcs/blob/master/text/0982-dst-coercion.md), use
31093109
[`CoerceUnsized`](https://doc.rust-lang.org/std/ops/trait.CoerceUnsized.html)
31103110
instead.
3111+
3112+
```
3113+
#![feature(coerce_unsized)]
3114+
3115+
use std::ops::CoerceUnsized;
3116+
3117+
pub struct MyType<T: ?Sized> {
3118+
field_with_unsized_type: T,
3119+
}
3120+
3121+
impl<T, U> CoerceUnsized<MyType<U>> for MyType<T>
3122+
where T: CoerceUnsized<U> {}
3123+
```
31113124
"##,
31123125

31133126
E0329: r##"

0 commit comments

Comments
 (0)