From 437c66cce5b13e18fa7ae09a4bb7fa9d86b01ec3 Mon Sep 17 00:00:00 2001 From: Lin Clark Date: Wed, 30 Nov 2016 21:32:14 -0500 Subject: [PATCH 1/2] Add error explanation for E0328. --- src/librustc_typeck/diagnostics.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 1a971be64d819..1a87a5e709b21 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -3087,6 +3087,29 @@ impl Foo for Bar { ``` "##, +E0328: r##" +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: + +```compile_fail,E0328 +#![feature(unsize)] + +use std::marker::Unsize; + +pub struct MyType; + +impl Unsize for MyType {} +``` + +If you are defining your own smart pointer type and would like to enable +conversion from a sized to an unsized type with the [DST coercion system] +(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. +"##, + E0329: r##" An attempt was made to access an associated constant through either a generic type parameter or `Self`. This is not supported yet. An example causing this @@ -4195,7 +4218,6 @@ register_diagnostics! { // E0249, // E0319, // trait impls for defaulted traits allowed just for structs/enums E0320, // recursive overflow during dropck - E0328, // cannot implement Unsize explicitly // E0372, // coherence not object safe E0377, // the trait `CoerceUnsized` may only be implemented for a coercion // between structures with the same definition From ac28aba886c92ff3b81347425c7b09cdfaf88ec8 Mon Sep 17 00:00:00 2001 From: Lin Clark Date: Thu, 5 Jan 2017 13:42:22 -0500 Subject: [PATCH 2/2] 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 1a87a5e709b21..28f4cacd635ca 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -3091,7 +3091,7 @@ E0328: r##" 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 @@ conversion from a sized to an unsized type with the [DST coercion system] (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##"