@@ -66,10 +66,42 @@ During macro expansion, for each element in the list of derives, the correspondi
66
66
r [attributes . derive. automatically_derived]
67
67
## The `automatically_derived ` attribute
68
68
69
- The * `automatically_derived ` attribute * is automatically added to [implementations ] created by the `derive ` attribute for built - in traits . It has no direct effect , but it may be used by tools and diagnostic lints to detect these automatically generated implementations .
69
+ r [attributes . derive. automatically_derived. intro]
70
+ The * `automatically_derived ` [attribute ][attributes ]* is used to annotate an [implementation ] to indicate that it was automatically created by a `derive ` attribute . It has no direct effect , but it may be used by tools and diagnostic lints to detect these automatically generated implementations .
71
+
72
+ > [! EXAMPLE ]
73
+ > The following is an example of what the [`Clone `] derive may generate for a struct named `Example `.
74
+ > ```rust
75
+ > # struct Example ;
76
+ > #[automatically_derived]
77
+ > impl :: core :: clone :: Clone for Example {
78
+ > #[inline]
79
+ > fn clone (& self ) -> Example {
80
+ > Example
81
+ > }
82
+ > }
83
+ > ```
84
+
85
+ r [attributes . derive. automatically_derived. syntax]
86
+ The `automatically_derived ` attribute uses the [MetaWord ] syntax and thus does not take any inputs .
87
+
88
+ r [attributes . derive. automatically_derived. allowed- positions ]
89
+ The `automatically_derived ` attribute may be placed on an [implementation ].
90
+
91
+ > [! NOTE ]
92
+ > `rustc ` currently warns in other positions .
93
+
94
+ r [attributes . derive. automatically_derived. duplicates]
95
+ Duplicate instances of the `automatically_derived ` attribute on the same implementation have no effect .
96
+
97
+ > [! NOTE ]
98
+ > `rustc ` currently warns on subsequent duplicate `automatically_derived ` attributes .
99
+
100
+ r [attributes . derive. automatically_derived. behavior]
101
+ The `automatically_derived ` attribute has no behavior .
70
102
71
103
[items ]: .. / items . md
72
104
[derive macros ]: .. / procedural - macros . md#derive - macros
73
- [implementations ]: .. / items / implementations . md
105
+ [implementation ]: .. / items / implementations . md
74
106
[items ]: .. / items . md
75
107
[procedural macros ]: .. / procedural - macros . md#derive - macros
0 commit comments