Skip to content

Commit

Permalink
Clean up E0375 explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Feb 29, 2020
1 parent abc3073 commit 6fba47f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/librustc_error_codes/error_codes/E0375.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
A struct with more than one field containing an unsized type cannot implement
`CoerceUnsized`. This only occurs when you are trying to coerce one of the
types in your struct to another type in the struct. In this case we try to
impl `CoerceUnsized` from `T` to `U` which are both types that the struct
takes. An [unsized type][1] is any type that the compiler doesn't know the
length or alignment of at compile time. Any struct containing an unsized type
is also unsized.
`CoerceUnsized` was implemented on a struct which contains more than one field
with an unsized type.

Example of erroneous code:
Erroneous code example:

```compile_fail,E0375
#![feature(coerce_unsized)]
Expand All @@ -22,6 +17,14 @@ struct Foo<T: ?Sized, U: ?Sized> {
impl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {}
```

A struct with more than one field containing an unsized type cannot implement
`CoerceUnsized`. This only occurs when you are trying to coerce one of the
types in your struct to another type in the struct. In this case we try to
impl `CoerceUnsized` from `T` to `U` which are both types that the struct
takes. An [unsized type][1] is any type that the compiler doesn't know the
length or alignment of at compile time. Any struct containing an unsized type
is also unsized.

`CoerceUnsized` only allows for coercion from a structure with a single
unsized type field to another struct with a single unsized type field.
In fact Rust only allows for a struct to have one unsized type in a struct
Expand Down

0 comments on commit 6fba47f

Please sign in to comment.