File tree 1 file changed +11
-8
lines changed
src/librustc_error_codes/error_codes
1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change 1
- A struct with more than one field containing an unsized type cannot implement
2
- ` CoerceUnsized ` . This only occurs when you are trying to coerce one of the
3
- types in your struct to another type in the struct. In this case we try to
4
- impl ` CoerceUnsized ` from ` T ` to ` U ` which are both types that the struct
5
- takes. An [ unsized type] [ 1 ] is any type that the compiler doesn't know the
6
- length or alignment of at compile time. Any struct containing an unsized type
7
- is also unsized.
1
+ ` CoerceUnsized ` was implemented on a struct which contains more than one field
2
+ with an unsized type.
8
3
9
- Example of erroneous code:
4
+ Erroneous code example :
10
5
11
6
``` compile_fail,E0375
12
7
#![feature(coerce_unsized)]
@@ -22,6 +17,14 @@ struct Foo<T: ?Sized, U: ?Sized> {
22
17
impl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {}
23
18
```
24
19
20
+ A struct with more than one field containing an unsized type cannot implement
21
+ ` CoerceUnsized ` . This only occurs when you are trying to coerce one of the
22
+ types in your struct to another type in the struct. In this case we try to
23
+ impl ` CoerceUnsized ` from ` T ` to ` U ` which are both types that the struct
24
+ takes. An [ unsized type] [ 1 ] is any type that the compiler doesn't know the
25
+ length or alignment of at compile time. Any struct containing an unsized type
26
+ is also unsized.
27
+
25
28
` CoerceUnsized ` only allows for coercion from a structure with a single
26
29
unsized type field to another struct with a single unsized type field.
27
30
In fact Rust only allows for a struct to have one unsized type in a struct
You can’t perform that action at this time.
0 commit comments