Skip to content

Commit cb9a686

Browse files
author
Nick Hamann
committed
Add long diagnostics for E0184, E0204, E0205, E0206, E0243, E0244.
1 parent 0170470 commit cb9a686

File tree

1 file changed

+108
-9
lines changed

1 file changed

+108
-9
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 108 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,114 @@ construct an instance of the following type using only safe code:
119119
```
120120
enum Empty {}
121121
```
122+
"##,
123+
124+
E0184: r##"
125+
Explicitly implementing both Drop and Copy for a type is currently disallowed.
126+
This feature can make some sense in theory, but the current implementation is
127+
incorrect and can lead to memory unsafety (see issue #20126), so it has been
128+
disabled for now.
129+
"##,
130+
131+
E0204: r##"
132+
An attempt to implement the `Copy` trait for a struct failed because one of the
133+
fields does not implement `Copy`. To fix this, you must implement `Copy` for the
134+
mentioned field. Note that this may not be possible, as in the example of
135+
136+
```
137+
struct Foo {
138+
foo : Vec<u32>,
139+
}
140+
141+
impl Copy for Foo { }
142+
```
143+
144+
This fails because `Vec<T>` does not implement `Copy` for any `T`.
145+
146+
Here's another example that will fail:
147+
148+
```
149+
#[derive(Copy)]
150+
struct Foo<'a> {
151+
ty: &'a mut bool,
152+
}
153+
```
154+
155+
This fails because `&mut T` is not `Copy`, even when `T` is `Copy` (as opposed
156+
to `&T`, which is).
157+
"##,
158+
159+
E0205: r##"
160+
An attempt to implement the `Copy` trait for an enum failed because one of the
161+
variants does not implement `Copy`. To fix this, you must implement `Copy` for
162+
the mentioned variant. Note that this may not be possible, as in the example of
163+
164+
```
165+
enum Foo {
166+
Bar(Vec<u32>),
167+
Baz,
168+
}
169+
170+
impl Copy for Foo { }
171+
```
172+
173+
This fails because `Vec<T>` does not implement `Copy` for any `T`.
174+
175+
Here's another example that will fail:
176+
177+
```
178+
#[derive(Copy)]
179+
enum Foo<'a> {
180+
Bar(&'a mut bool),
181+
Baz
182+
}
183+
```
184+
185+
This fails because `&mut T` is not `Copy`, even when `T` is `Copy` (as opposed
186+
to `&T`, which is).
187+
"##,
188+
189+
E0206: r##"
190+
You can only implement `Copy` for a struct or enum. For example, both of the
191+
following examples will fail, because neither `i32` nor `&'static mut Bar` is
192+
a struct or enum:
193+
194+
```
195+
type Foo = i32;
196+
impl Copy for Foo { } // error
197+
198+
#[derive(Copy, Clone)]
199+
struct Bar;
200+
impl Copy for &'static mut Bar { } // error
201+
```
202+
"##,
203+
204+
E0243: r##"
205+
This error indicates that not enough type parameters were found in a type or
206+
trait.
207+
208+
For example, the `Foo` struct below is defined to be generic in `T`, but the
209+
type parameter is missing in the definition of `Bar`:
210+
211+
```
212+
struct Foo<T> { x: T }
213+
214+
struct Bar { x: Foo }
215+
```
216+
"##,
217+
218+
E0244: r##"
219+
This error indicates that too many type parameters were found in a type or
220+
trait.
221+
222+
For example, the `Foo` struct below has no type parameters, but is supplied
223+
with two in the definition of `Bar`:
224+
225+
```
226+
struct Foo { x: bool }
227+
228+
struct Bar<S, T> { x: Foo<S, T> }
229+
```
122230
"##
123231

124232
}
@@ -204,7 +312,6 @@ register_diagnostics! {
204312
E0178,
205313
E0182,
206314
E0183,
207-
E0184,
208315
E0185,
209316
E0186,
210317
E0187, // can't infer the kind of the closure
@@ -226,12 +333,6 @@ register_diagnostics! {
226333
E0202, // associated items are not allowed in inherent impls
227334
E0203, // type parameter has more than one relaxed default bound,
228335
// and only one is supported
229-
E0204, // trait `Copy` may not be implemented for this type; field
230-
// does not implement `Copy`
231-
E0205, // trait `Copy` may not be implemented for this type; variant
232-
// does not implement `copy`
233-
E0206, // trait `Copy` may not be implemented for this type; type is
234-
// not a structure or enumeration
235336
E0207, // type parameter is not constrained by the impl trait, self type, or predicate
236337
E0208,
237338
E0209, // builtin traits can only be implemented on structs or enums
@@ -268,8 +369,6 @@ register_diagnostics! {
268369
E0240,
269370
E0241,
270371
E0242, // internal error looking up a definition
271-
E0243, // wrong number of type arguments
272-
E0244, // wrong number of type arguments
273372
E0245, // not a trait
274373
E0246, // illegal recursive type
275374
E0247, // found module name used as a type

0 commit comments

Comments
 (0)