File tree Expand file tree Collapse file tree 1 file changed +22
-20
lines changed
src/librustc_error_codes/error_codes Expand file tree Collapse file tree 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+
121The ` DispatchFromDyn ` trait currently can only be implemented for
222builtin pointer types and structs that are newtype wrappers around them
323— that is, the struct must have only one field (except for` PhantomData ` ),
424and that field must itself implement ` DispatchFromDyn ` .
525
6- Examples:
7-
826```
927#![feature(dispatch_from_dyn, unsize)]
1028use std::{
2038{}
2139```
2240
41+ Another example:
42+
2343```
2444#![feature(dispatch_from_dyn)]
2545use std::{
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- ```
You can’t perform that action at this time.
0 commit comments