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