Skip to content

Commit 437c66c

Browse files
committed
Add error explanation for E0328.
1 parent 74e5b7d commit 437c66c

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3087,6 +3087,29 @@ impl Foo for Bar {
30873087
```
30883088
"##,
30893089

3090+
E0328: r##"
3091+
The Unsize trait should not be implemented directly. All implementations of
3092+
Unsize are provided automatically by the compiler.
3093+
3094+
Here's an example of this error:
3095+
3096+
```compile_fail,E0328
3097+
#![feature(unsize)]
3098+
3099+
use std::marker::Unsize;
3100+
3101+
pub struct MyType;
3102+
3103+
impl<T> Unsize<T> for MyType {}
3104+
```
3105+
3106+
If you are defining your own smart pointer type and would like to enable
3107+
conversion from a sized to an unsized type with the [DST coercion system]
3108+
(https://github.com/rust-lang/rfcs/blob/master/text/0982-dst-coercion.md), use
3109+
[`CoerceUnsized`](https://doc.rust-lang.org/std/ops/trait.CoerceUnsized.html)
3110+
instead.
3111+
"##,
3112+
30903113
E0329: r##"
30913114
An attempt was made to access an associated constant through either a generic
30923115
type parameter or `Self`. This is not supported yet. An example causing this
@@ -4195,7 +4218,6 @@ register_diagnostics! {
41954218
// E0249,
41964219
// E0319, // trait impls for defaulted traits allowed just for structs/enums
41974220
E0320, // recursive overflow during dropck
4198-
E0328, // cannot implement Unsize explicitly
41994221
// E0372, // coherence not object safe
42004222
E0377, // the trait `CoerceUnsized` may only be implemented for a coercion
42014223
// between structures with the same definition

0 commit comments

Comments
 (0)