File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
src/librustc_error_codes/error_codes Expand file tree Collapse file tree 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.
83
9- Example of erroneous code:
4+ Erroneous code example :
105
116``` compile_fail,E0375
127#![feature(coerce_unsized)]
@@ -22,6 +17,14 @@ struct Foo<T: ?Sized, U: ?Sized> {
2217impl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {}
2318```
2419
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+
2528` CoerceUnsized ` only allows for coercion from a structure with a single
2629unsized type field to another struct with a single unsized type field.
2730In 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