From ac28aba886c92ff3b81347425c7b09cdfaf88ec8 Mon Sep 17 00:00:00 2001 From: Lin Clark Date: Thu, 5 Jan 2017 13:42:22 -0500 Subject: [PATCH] added how to fix the problem block --- src/librustc_typeck/diagnostics.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 1a87a5e709b2..28f4cacd635c 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -3091,7 +3091,7 @@ impl Foo for Bar { The Unsize trait should not be implemented directly. All implementations of Unsize are provided automatically by the compiler. -Here's an example of this error: +Erroneous code example: ```compile_fail,E0328 #![feature(unsize)] @@ -3108,6 +3108,19 @@ impl Unsize for MyType {} (https://github.com/rust-lang/rfcs/blob/master/text/0982-dst-coercion.md), use [`CoerceUnsized`](https://doc.rust-lang.org/std/ops/trait.CoerceUnsized.html) instead. + +``` +#![feature(coerce_unsized)] + +use std::ops::CoerceUnsized; + +pub struct MyType { + field_with_unsized_type: T, +} + +impl CoerceUnsized> for MyType + where T: CoerceUnsized {} +``` "##, E0329: r##"