Skip to content

Commit d3a5a5d

Browse files
authored
Rollup merge of #69607 - GuillaumeGomez:cleanup-e0376, r=Dylan-DPC
Clean up E0376 explanation r? @Dylan-DPC
2 parents 22a0391 + dd142b1 commit d3a5a5d

File tree

1 file changed

+11
-10
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+11
-10
lines changed

src/librustc_error_codes/error_codes/E0376.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
The type you are trying to impl `CoerceUnsized` for is not a struct.
2-
`CoerceUnsized` can only be implemented for a struct. Unsized types are
3-
already able to be coerced without an implementation of `CoerceUnsized`
4-
whereas a struct containing an unsized type needs to know the unsized type
5-
field it's containing is able to be coerced. An [unsized type][1]
6-
is any type that the compiler doesn't know the length or alignment of at
7-
compile time. Any struct containing an unsized type is also unsized.
8-
9-
[1]: https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait
1+
`CoerceUnsized` was implemented on something that isn't a struct.
102

11-
Example of erroneous code:
3+
Erroneous code example:
124

135
```compile_fail,E0376
146
#![feature(coerce_unsized)]
@@ -22,6 +14,15 @@ struct Foo<T: ?Sized> {
2214
impl<T, U> CoerceUnsized<U> for Foo<T> {}
2315
```
2416

17+
`CoerceUnsized` can only be implemented for a struct. Unsized types are
18+
already able to be coerced without an implementation of `CoerceUnsized`
19+
whereas a struct containing an unsized type needs to know the unsized type
20+
field it's containing is able to be coerced. An [unsized type][1]
21+
is any type that the compiler doesn't know the length or alignment of at
22+
compile time. Any struct containing an unsized type is also unsized.
23+
24+
[1]: https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait
25+
2526
The `CoerceUnsized` trait takes a struct type. Make sure the type you are
2627
providing to `CoerceUnsized` is a struct with only the last field containing an
2728
unsized type.

0 commit comments

Comments
 (0)