@@ -66,13 +66,44 @@ 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
70
- [implementations ] created by the `derive ` attribute for built - in traits . It
71
- has no direct effect , but it may be used by tools and diagnostic lints to
72
- 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 macro ]. 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
+ > Given [`#[derive(Clone )]`][macro @ Clone ] on `struct Example `, the [derive macro ] may produce :
74
+ >
75
+ > ```rust
76
+ > # struct Example ;
77
+ > #[automatically_derived]
78
+ > impl :: core :: clone :: Clone for Example {
79
+ > #[inline]
80
+ > fn clone (& self ) -> Self {
81
+ > Example
82
+ > }
83
+ > }
84
+ > ```
85
+
86
+ r [attributes . derive. automatically_derived. syntax]
87
+ The `automatically_derived ` attribute uses the [MetaWord ] syntax and so does not accept any arguments .
88
+
89
+ r [attributes . derive. automatically_derived. allowed- positions ]
90
+ The `automatically_derived ` attribute may be placed on an [implementation ].
91
+
92
+ > [! NOTE ]
93
+ > `rustc ` currently accepts the attribute in other positions but lints against it .
94
+
95
+ r [attributes . derive. automatically_derived. duplicates]
96
+ Duplicate instances of the `automatically_derived ` attribute on the same implementation have no effect .
97
+
98
+ > [! NOTE ]
99
+ > `rustc ` lints against duplicate use of this attribute.
100
+
101
+ r[attributes. derive. automatically_derived. behavior]
102
+ The `automatically_derived` attribute has no behavior.
73
103
74
104
[items]: .. / items. md
105
+ [derive macro ]: macro . proc. derive
75
106
[derive macros]: .. / procedural- macros. md#derive- macros
76
- [implementations ]: .. / items / implementations . md
107
+ [implementation ]: .. / items/ implementations. md
77
108
[items]: .. / items. md
78
109
[procedural macros]: .. / procedural- macros. md#derive- macros
0 commit comments