Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 11ff6dd

Browse files
authoredMar 3, 2020
Rollup merge of rust-lang#69634 - GuillaumeGomez:clean-up-e0378, r=Dylan-DPC
clean up E0378 explanation r? @Dylan-DPC
2 parents 473c7a8 + ba49ed0 commit 11ff6dd

File tree

1 file changed

+22
-20
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+22
-20
lines changed
 

‎src/librustc_error_codes/error_codes/E0378.md

+22-20
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1+
The `DispatchFromDyn` trait was implemented on something which is not a pointer
2+
or a newtype wrapper around a pointer.
3+
4+
Erroneous code example:
5+
6+
```compile-fail,E0378
7+
#![feature(dispatch_from_dyn)]
8+
use std::ops::DispatchFromDyn;
9+
10+
struct WrapperExtraField<T> {
11+
ptr: T,
12+
extra_stuff: i32,
13+
}
14+
15+
impl<T, U> DispatchFromDyn<WrapperExtraField<U>> for WrapperExtraField<T>
16+
where
17+
T: DispatchFromDyn<U>,
18+
{}
19+
```
20+
121
The `DispatchFromDyn` trait currently can only be implemented for
222
builtin pointer types and structs that are newtype wrappers around them
323
— that is, the struct must have only one field (except for`PhantomData`),
424
and that field must itself implement `DispatchFromDyn`.
525

6-
Examples:
7-
826
```
927
#![feature(dispatch_from_dyn, unsize)]
1028
use std::{
@@ -20,6 +38,8 @@ where
2038
{}
2139
```
2240

41+
Another example:
42+
2343
```
2444
#![feature(dispatch_from_dyn)]
2545
use std::{
@@ -37,21 +57,3 @@ where
3757
T: DispatchFromDyn<U>,
3858
{}
3959
```
40-
41-
Example of illegal `DispatchFromDyn` implementation
42-
(illegal because of extra field)
43-
44-
```compile-fail,E0378
45-
#![feature(dispatch_from_dyn)]
46-
use std::ops::DispatchFromDyn;
47-
48-
struct WrapperExtraField<T> {
49-
ptr: T,
50-
extra_stuff: i32,
51-
}
52-
53-
impl<T, U> DispatchFromDyn<WrapperExtraField<U>> for WrapperExtraField<T>
54-
where
55-
T: DispatchFromDyn<U>,
56-
{}
57-
```

0 commit comments

Comments
 (0)
Please sign in to comment.