]>
Commit | Line | Data |
---|---|---|
94222f64 XL |
1 | An inherent `impl` was written on a dyn auto trait. |
2 | ||
3 | Erroneous code example: | |
4 | ||
5 | ```compile_fail,E0785 | |
6 | #![feature(auto_traits)] | |
7 | ||
8 | auto trait AutoTrait {} | |
9 | ||
10 | impl dyn AutoTrait {} | |
11 | ``` | |
12 | ||
13 | Dyn objects allow any number of auto traits, plus at most one non-auto trait. | |
14 | The non-auto trait becomes the "principal trait". | |
15 | ||
16 | When checking if an impl on a dyn trait is coherent, the principal trait is | |
17 | normally the only one considered. Since the erroneous code has no principal | |
18 | trait, it cannot be implemented at all. | |
19 | ||
20 | Working example: | |
21 | ||
22 | ``` | |
23 | #![feature(auto_traits)] | |
24 | ||
25 | trait PrincipalTrait {} | |
26 | ||
27 | auto trait AutoTrait {} | |
28 | ||
29 | impl dyn PrincipalTrait + AutoTrait + Send {} | |
30 | ``` |