File tree 1 file changed +22
-20
lines changed
src/librustc_error_codes/error_codes
1 file changed +22
-20
lines changed Original file line number Diff line number Diff line change
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
+
1
21
The ` DispatchFromDyn ` trait currently can only be implemented for
2
22
builtin pointer types and structs that are newtype wrappers around them
3
23
— that is, the struct must have only one field (except for` PhantomData ` ),
4
24
and that field must itself implement ` DispatchFromDyn ` .
5
25
6
- Examples:
7
-
8
26
```
9
27
#![feature(dispatch_from_dyn, unsize)]
10
28
use std::{
20
38
{}
21
39
```
22
40
41
+ Another example:
42
+
23
43
```
24
44
#![feature(dispatch_from_dyn)]
25
45
use std::{
37
57
T: DispatchFromDyn<U>,
38
58
{}
39
59
```
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
- ```
You can’t perform that action at this time.
0 commit comments