Skip to content

Commit ddbfcd2

Browse files
authored
Apply #[automatically_derived] to all generated implementations (#92)
1 parent 2ce02fb commit ddbfcd2

File tree

14 files changed

+187
-0
lines changed

14 files changed

+187
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Fixed
11+
- Apply `#[automatically_derived]` to all generated implementations.
12+
813
## [1.2.6] - 2023-12-04
914

1015
### Fixed

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ fn generate_impl(
641641
let ident = item.ident();
642642
let path = trait_.impl_path(trait_);
643643
let mut output = quote! {
644+
#[automatically_derived]
644645
impl #imp #path for #ident #ty
645646
#where_clause
646647
{
@@ -650,6 +651,7 @@ fn generate_impl(
650651

651652
if let Some((path, body)) = trait_.additional_impl(trait_) {
652653
output.extend(quote! {
654+
#[automatically_derived]
653655
impl #imp #path for #ident #ty
654656
#where_clause
655657
{

src/test/basic.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ fn struct_() -> Result<()> {
1313
}
1414
},
1515
quote! {
16+
#[automatically_derived]
1617
impl<T> ::core::clone::Clone for Test<T> {
1718
#[inline]
1819
fn clone(&self) -> Self {
1920
*self
2021
}
2122
}
2223

24+
#[automatically_derived]
2325
impl<T> ::core::marker::Copy for Test<T>
2426
{ }
2527

28+
#[automatically_derived]
2629
impl<T> ::core::fmt::Debug for Test<T> {
2730
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
2831
match self {
@@ -35,12 +38,14 @@ fn struct_() -> Result<()> {
3538
}
3639
}
3740

41+
#[automatically_derived]
3842
impl<T> ::core::default::Default for Test<T> {
3943
fn default() -> Self {
4044
Test { field: ::core::default::Default::default() }
4145
}
4246
}
4347

48+
#[automatically_derived]
4449
impl<T> ::core::cmp::Eq for Test<T> {
4550
#[inline]
4651
fn assert_receiver_is_total_eq(&self) {
@@ -51,6 +56,7 @@ fn struct_() -> Result<()> {
5156
}
5257
}
5358

59+
#[automatically_derived]
5460
impl<T> ::core::hash::Hash for Test<T> {
5561
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
5662
match self {
@@ -59,6 +65,7 @@ fn struct_() -> Result<()> {
5965
}
6066
}
6167

68+
#[automatically_derived]
6269
impl<T> ::core::cmp::Ord for Test<T> {
6370
#[inline]
6471
fn cmp(&self, __other: &Self) -> ::core::cmp::Ordering {
@@ -72,6 +79,7 @@ fn struct_() -> Result<()> {
7279
}
7380
}
7481

82+
#[automatically_derived]
7583
impl<T> ::core::cmp::PartialEq for Test<T> {
7684
#[inline]
7785
fn eq(&self, __other: &Self) -> bool {
@@ -82,6 +90,7 @@ fn struct_() -> Result<()> {
8290
}
8391
}
8492

93+
#[automatically_derived]
8594
impl<T> ::core::cmp::PartialOrd for Test<T> {
8695
#[inline]
8796
fn partial_cmp(&self, __other: &Self) -> ::core::option::Option<::core::cmp::Ordering> {
@@ -100,16 +109,19 @@ fn tuple() -> Result<()> {
100109
struct Test<T>(std::marker::PhantomData<T>);
101110
},
102111
quote! {
112+
#[automatically_derived]
103113
impl<T> ::core::clone::Clone for Test<T> {
104114
#[inline]
105115
fn clone(&self) -> Self {
106116
*self
107117
}
108118
}
109119

120+
#[automatically_derived]
110121
impl<T> ::core::marker::Copy for Test<T>
111122
{ }
112123

124+
#[automatically_derived]
113125
impl<T> ::core::fmt::Debug for Test<T> {
114126
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
115127
match self {
@@ -122,12 +134,14 @@ fn tuple() -> Result<()> {
122134
}
123135
}
124136

137+
#[automatically_derived]
125138
impl<T> ::core::default::Default for Test<T> {
126139
fn default() -> Self {
127140
Test(::core::default::Default::default())
128141
}
129142
}
130143

144+
#[automatically_derived]
131145
impl<T> ::core::cmp::Eq for Test<T> {
132146
#[inline]
133147
fn assert_receiver_is_total_eq(&self) {
@@ -138,6 +152,7 @@ fn tuple() -> Result<()> {
138152
}
139153
}
140154

155+
#[automatically_derived]
141156
impl<T> ::core::hash::Hash for Test<T> {
142157
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
143158
match self {
@@ -146,6 +161,7 @@ fn tuple() -> Result<()> {
146161
}
147162
}
148163

164+
#[automatically_derived]
149165
impl<T> ::core::cmp::Ord for Test<T> {
150166
#[inline]
151167
fn cmp(&self, __other: &Self) -> ::core::cmp::Ordering {
@@ -159,6 +175,7 @@ fn tuple() -> Result<()> {
159175
}
160176
}
161177

178+
#[automatically_derived]
162179
impl<T> ::core::cmp::PartialEq for Test<T> {
163180
#[inline]
164181
fn eq(&self, __other: &Self) -> bool {
@@ -169,6 +186,7 @@ fn tuple() -> Result<()> {
169186
}
170187
}
171188

189+
#[automatically_derived]
172190
impl<T> ::core::cmp::PartialOrd for Test<T> {
173191
#[inline]
174192
fn partial_cmp(&self, __other: &Self) -> ::core::option::Option<::core::cmp::Ordering> {
@@ -223,16 +241,19 @@ fn enum_() -> Result<()> {
223241
}
224242
},
225243
quote! {
244+
#[automatically_derived]
226245
impl<T> ::core::clone::Clone for Test<T> {
227246
#[inline]
228247
fn clone(&self) -> Self {
229248
*self
230249
}
231250
}
232251

252+
#[automatically_derived]
233253
impl<T> ::core::marker::Copy for Test<T>
234254
{ }
235255

256+
#[automatically_derived]
236257
impl<T> ::core::fmt::Debug for Test<T> {
237258
fn fmt(&self, __f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
238259
match self {
@@ -259,12 +280,14 @@ fn enum_() -> Result<()> {
259280
}
260281
}
261282

283+
#[automatically_derived]
262284
impl<T> ::core::default::Default for Test<T> {
263285
fn default() -> Self {
264286
Test::E
265287
}
266288
}
267289

290+
#[automatically_derived]
268291
impl<T> ::core::cmp::Eq for Test<T> {
269292
#[inline]
270293
fn assert_receiver_is_total_eq(&self) {
@@ -276,6 +299,7 @@ fn enum_() -> Result<()> {
276299
}
277300
}
278301

302+
#[automatically_derived]
279303
impl<T> ::core::hash::Hash for Test<T> {
280304
fn hash<__H: ::core::hash::Hasher>(&self, __state: &mut __H) {
281305
match self {
@@ -300,6 +324,7 @@ fn enum_() -> Result<()> {
300324
}
301325
}
302326

327+
#[automatically_derived]
303328
impl<T> ::core::cmp::Ord for Test<T> {
304329
#[inline]
305330
fn cmp(&self, __other: &Self) -> ::core::cmp::Ordering {
@@ -325,6 +350,7 @@ fn enum_() -> Result<()> {
325350
}
326351
}
327352

353+
#[automatically_derived]
328354
impl<T> ::core::cmp::PartialEq for Test<T> {
329355
#[inline]
330356
fn eq(&self, __other: &Self) -> bool {
@@ -342,6 +368,7 @@ fn enum_() -> Result<()> {
342368
}
343369
}
344370

371+
#[automatically_derived]
345372
impl<T> ::core::cmp::PartialOrd for Test<T> {
346373
#[inline]
347374
fn partial_cmp(&self, __other: &Self) -> ::core::option::Option<::core::cmp::Ordering> {
@@ -363,13 +390,15 @@ fn union_() -> Result<()> {
363390
}
364391
},
365392
quote! {
393+
#[automatically_derived]
366394
impl<T> ::core::clone::Clone for Test<T> {
367395
#[inline]
368396
fn clone(&self) -> Self {
369397
*self
370398
}
371399
}
372400

401+
#[automatically_derived]
373402
impl<T> ::core::marker::Copy for Test<T>
374403
{ }
375404
},

0 commit comments

Comments
 (0)