Skip to content

Commit e32aac7

Browse files
committed
chore: use auto-derived copy/clone impls
Unless there is something really magical, it doesn't seem to make sense to have manual impl for the most commonly used traits
1 parent 0fe1d45 commit e32aac7

File tree

22 files changed

+60
-321
lines changed

22 files changed

+60
-321
lines changed

src/fuchsia/mod.rs

+7-30
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,16 @@ pub type rlim_t = c_ulonglong;
8181
// FIXME(fuchsia): why are these uninhabited types? that seems... wrong?
8282
// Presumably these should be `()` or an `extern type` (when that stabilizes).
8383
#[cfg_attr(feature = "extra_traits", derive(Debug))]
84+
#[derive(Clone, Copy)]
8485
pub enum timezone {}
85-
impl Copy for timezone {}
86-
impl Clone for timezone {
87-
fn clone(&self) -> timezone {
88-
*self
89-
}
90-
}
86+
9187
#[cfg_attr(feature = "extra_traits", derive(Debug))]
88+
#[derive(Clone, Copy)]
9289
pub enum DIR {}
93-
impl Copy for DIR {}
94-
impl Clone for DIR {
95-
fn clone(&self) -> DIR {
96-
*self
97-
}
98-
}
9990

10091
#[cfg_attr(feature = "extra_traits", derive(Debug))]
92+
#[derive(Clone, Copy)]
10193
pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct
102-
impl Copy for fpos64_t {}
103-
impl Clone for fpos64_t {
104-
fn clone(&self) -> fpos64_t {
105-
*self
106-
}
107-
}
10894

10995
// PUB_STRUCT
11096

@@ -3541,21 +3527,12 @@ fn __MHDR_END(mhdr: *const msghdr) -> *mut c_uchar {
35413527
extern "C" {}
35423528

35433529
#[cfg_attr(feature = "extra_traits", derive(Debug))]
3530+
#[derive(Clone, Copy)]
35443531
pub enum FILE {}
3545-
impl Copy for FILE {}
3546-
impl Clone for FILE {
3547-
fn clone(&self) -> FILE {
3548-
*self
3549-
}
3550-
}
3532+
35513533
#[cfg_attr(feature = "extra_traits", derive(Debug))]
3534+
#[derive(Clone, Copy)]
35523535
pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct
3553-
impl Copy for fpos_t {}
3554-
impl Clone for fpos_t {
3555-
fn clone(&self) -> fpos_t {
3556-
*self
3557-
}
3558-
}
35593536

35603537
extern "C" {
35613538
pub fn isalnum(c: c_int) -> c_int;

src/solid/mod.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -396,21 +396,12 @@ pub const SIGUSR2: c_int = 31;
396396
pub const SIGPWR: c_int = 32;
397397

398398
#[cfg_attr(feature = "extra_traits", derive(Debug))]
399+
#[derive(Clone, Copy)]
399400
pub enum FILE {}
400-
impl Copy for FILE {}
401-
impl Clone for FILE {
402-
fn clone(&self) -> FILE {
403-
*self
404-
}
405-
}
401+
406402
#[cfg_attr(feature = "extra_traits", derive(Debug))]
403+
#[derive(Clone, Copy)]
407404
pub enum fpos_t {}
408-
impl Copy for fpos_t {}
409-
impl Clone for fpos_t {
410-
fn clone(&self) -> fpos_t {
411-
*self
412-
}
413-
}
414405

415406
extern "C" {
416407
// ctype.h

src/unix/bsd/apple/mod.rs

+4-24
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,11 @@ pub type attrgroup_t = u32;
176176
pub type vol_capabilities_set_t = [u32; 4];
177177

178178
#[cfg_attr(feature = "extra_traits", derive(Debug))]
179+
#[derive(Clone, Copy)]
179180
pub enum timezone {}
180-
impl Copy for timezone {}
181-
impl Clone for timezone {
182-
fn clone(&self) -> timezone {
183-
*self
184-
}
185-
}
186181

187182
#[cfg_attr(feature = "extra_traits", derive(Debug))]
183+
#[derive(Clone, Copy)]
188184
#[repr(u32)]
189185
pub enum qos_class_t {
190186
QOS_CLASS_USER_INTERACTIVE = 0x21,
@@ -194,14 +190,9 @@ pub enum qos_class_t {
194190
QOS_CLASS_BACKGROUND = 0x09,
195191
QOS_CLASS_UNSPECIFIED = 0x00,
196192
}
197-
impl Copy for qos_class_t {}
198-
impl Clone for qos_class_t {
199-
fn clone(&self) -> qos_class_t {
200-
*self
201-
}
202-
}
203193

204194
#[cfg_attr(feature = "extra_traits", derive(Debug))]
195+
#[derive(Clone, Copy)]
205196
#[repr(u32)]
206197
pub enum sysdir_search_path_directory_t {
207198
SYSDIR_DIRECTORY_APPLICATION = 1,
@@ -229,14 +220,9 @@ pub enum sysdir_search_path_directory_t {
229220
SYSDIR_DIRECTORY_ALL_APPLICATIONS = 100,
230221
SYSDIR_DIRECTORY_ALL_LIBRARIES = 101,
231222
}
232-
impl Copy for sysdir_search_path_directory_t {}
233-
impl Clone for sysdir_search_path_directory_t {
234-
fn clone(&self) -> sysdir_search_path_directory_t {
235-
*self
236-
}
237-
}
238223

239224
#[cfg_attr(feature = "extra_traits", derive(Debug))]
225+
#[derive(Clone, Copy)]
240226
#[repr(u32)]
241227
pub enum sysdir_search_path_domain_mask_t {
242228
SYSDIR_DOMAIN_MASK_USER = (1 << 0),
@@ -245,12 +231,6 @@ pub enum sysdir_search_path_domain_mask_t {
245231
SYSDIR_DOMAIN_MASK_SYSTEM = (1 << 3),
246232
SYSDIR_DOMAIN_MASK_ALL = 0x0ffff,
247233
}
248-
impl Copy for sysdir_search_path_domain_mask_t {}
249-
impl Clone for sysdir_search_path_domain_mask_t {
250-
fn clone(&self) -> sysdir_search_path_domain_mask_t {
251-
*self
252-
}
253-
}
254234

255235
s! {
256236
pub struct ip_mreq {

src/unix/bsd/freebsdlike/dragonfly/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,8 @@ pub type vm_map_entry_t = *mut vm_map_entry;
4646
pub type pmap = __c_anonymous_pmap;
4747

4848
#[cfg_attr(feature = "extra_traits", derive(Debug))]
49+
#[derive(Clone, Copy)]
4950
pub enum sem {}
50-
impl Copy for sem {}
51-
impl Clone for sem {
52-
fn clone(&self) -> sem {
53-
*self
54-
}
55-
}
5651

5752
e! {
5853
#[repr(u32)]

src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::prelude::*;
33

44
#[repr(C)]
55
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
6+
#[derive(Clone, Copy)]
67
pub struct stat {
78
pub st_dev: crate::dev_t,
89
pub st_ino: crate::ino_t,
@@ -27,10 +28,3 @@ pub struct stat {
2728
pub st_birthtime_nsec: c_long,
2829
__unused: [u8; 8],
2930
}
30-
31-
impl Copy for crate::stat {}
32-
impl Clone for crate::stat {
33-
fn clone(&self) -> crate::stat {
34-
*self
35-
}
36-
}

src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::prelude::*;
33

44
#[repr(C)]
55
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
6+
#[derive(Clone, Copy)]
67
pub struct stat {
78
pub st_dev: crate::dev_t,
89
pub st_ino: crate::ino_t,
@@ -26,10 +27,3 @@ pub struct stat {
2627
pub st_birthtime: crate::time_t,
2728
pub st_birthtime_nsec: c_long,
2829
}
29-
30-
impl Copy for crate::stat {}
31-
impl Clone for crate::stat {
32-
fn clone(&self) -> crate::stat {
33-
*self
34-
}
35-
}

src/unix/bsd/freebsdlike/freebsd/mod.rs

+9-55
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,17 @@ pub type sctp_assoc_t = u32;
5151
pub type eventfd_t = u64;
5252

5353
#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))]
54+
#[derive(Clone, Copy)]
5455
#[repr(u32)]
5556
pub enum devstat_support_flags {
5657
DEVSTAT_ALL_SUPPORTED = 0x00,
5758
DEVSTAT_NO_BLOCKSIZE = 0x01,
5859
DEVSTAT_NO_ORDERED_TAGS = 0x02,
5960
DEVSTAT_BS_UNAVAILABLE = 0x04,
6061
}
61-
impl Copy for devstat_support_flags {}
62-
impl Clone for devstat_support_flags {
63-
fn clone(&self) -> devstat_support_flags {
64-
*self
65-
}
66-
}
6762

6863
#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))]
64+
#[derive(Clone, Copy)]
6965
#[repr(u32)]
7066
pub enum devstat_trans_flags {
7167
DEVSTAT_NO_DATA = 0x00,
@@ -74,44 +70,28 @@ pub enum devstat_trans_flags {
7470
DEVSTAT_FREE = 0x03,
7571
}
7672

77-
impl Copy for devstat_trans_flags {}
78-
impl Clone for devstat_trans_flags {
79-
fn clone(&self) -> devstat_trans_flags {
80-
*self
81-
}
82-
}
83-
8473
#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))]
74+
#[derive(Clone, Copy)]
8575
#[repr(u32)]
8676
pub enum devstat_tag_type {
8777
DEVSTAT_TAG_SIMPLE = 0x00,
8878
DEVSTAT_TAG_HEAD = 0x01,
8979
DEVSTAT_TAG_ORDERED = 0x02,
9080
DEVSTAT_TAG_NONE = 0x03,
9181
}
92-
impl Copy for devstat_tag_type {}
93-
impl Clone for devstat_tag_type {
94-
fn clone(&self) -> devstat_tag_type {
95-
*self
96-
}
97-
}
9882

9983
#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))]
84+
#[derive(Clone, Copy)]
10085
#[repr(u32)]
10186
pub enum devstat_match_flags {
10287
DEVSTAT_MATCH_NONE = 0x00,
10388
DEVSTAT_MATCH_TYPE = 0x01,
10489
DEVSTAT_MATCH_IF = 0x02,
10590
DEVSTAT_MATCH_PASS = 0x04,
10691
}
107-
impl Copy for devstat_match_flags {}
108-
impl Clone for devstat_match_flags {
109-
fn clone(&self) -> devstat_match_flags {
110-
*self
111-
}
112-
}
11392

11493
#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))]
94+
#[derive(Clone, Copy)]
11595
#[repr(u32)]
11696
pub enum devstat_priority {
11797
DEVSTAT_PRIORITY_MIN = 0x000,
@@ -125,14 +105,9 @@ pub enum devstat_priority {
125105
DEVSTAT_PRIORITY_ARRAY = 0x120,
126106
DEVSTAT_PRIORITY_MAX = 0xfff,
127107
}
128-
impl Copy for devstat_priority {}
129-
impl Clone for devstat_priority {
130-
fn clone(&self) -> devstat_priority {
131-
*self
132-
}
133-
}
134108

135109
#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))]
110+
#[derive(Clone, Copy)]
136111
#[repr(u32)]
137112
pub enum devstat_type_flags {
138113
DEVSTAT_TYPE_DIRECT = 0x000,
@@ -157,14 +132,9 @@ pub enum devstat_type_flags {
157132
DEVSTAT_TYPE_IF_MASK = 0x0f0,
158133
DEVSTAT_TYPE_PASS = 0x100,
159134
}
160-
impl Copy for devstat_type_flags {}
161-
impl Clone for devstat_type_flags {
162-
fn clone(&self) -> devstat_type_flags {
163-
*self
164-
}
165-
}
166135

167136
#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))]
137+
#[derive(Clone, Copy)]
168138
#[repr(u32)]
169139
pub enum devstat_metric {
170140
DSM_NONE,
@@ -214,27 +184,16 @@ pub enum devstat_metric {
214184
DSM_TOTAL_BUSY_TIME,
215185
DSM_MAX,
216186
}
217-
impl Copy for devstat_metric {}
218-
impl Clone for devstat_metric {
219-
fn clone(&self) -> devstat_metric {
220-
*self
221-
}
222-
}
223187

224188
#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))]
189+
#[derive(Clone, Copy)]
225190
#[repr(u32)]
226191
pub enum devstat_select_mode {
227192
DS_SELECT_ADD,
228193
DS_SELECT_ONLY,
229194
DS_SELECT_REMOVE,
230195
DS_SELECT_ADDONLY,
231196
}
232-
impl Copy for devstat_select_mode {}
233-
impl Clone for devstat_select_mode {
234-
fn clone(&self) -> devstat_select_mode {
235-
*self
236-
}
237-
}
238197

239198
s! {
240199
pub struct __c_anonymous_sigev_thread {
@@ -2600,6 +2559,7 @@ cfg_if! {
26002559
}
26012560

26022561
#[cfg_attr(feature = "extra_traits", derive(Debug))]
2562+
#[derive(Clone, Copy)]
26032563
#[repr(u32)]
26042564
pub enum dot3Vendors {
26052565
dot3VendorAMD = 1,
@@ -2609,12 +2569,6 @@ pub enum dot3Vendors {
26092569
dot3VendorDigital = 6,
26102570
dot3VendorWesternDigital = 7,
26112571
}
2612-
impl Copy for dot3Vendors {}
2613-
impl Clone for dot3Vendors {
2614-
fn clone(&self) -> dot3Vendors {
2615-
*self
2616-
}
2617-
}
26182572

26192573
// aio.h
26202574
pub const LIO_VECTORED: c_int = 4;

src/unix/bsd/freebsdlike/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,8 @@ cfg_if! {
6060
// link.h
6161

6262
#[cfg_attr(feature = "extra_traits", derive(Debug))]
63+
#[derive(Clone, Copy)]
6364
pub enum timezone {}
64-
impl Copy for timezone {}
65-
impl Clone for timezone {
66-
fn clone(&self) -> timezone {
67-
*self
68-
}
69-
}
7065

7166
impl siginfo_t {
7267
pub unsafe fn si_addr(&self) -> *mut c_void {

src/unix/bsd/netbsdlike/mod.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,12 @@ pub type sem_t = *mut sem;
1717
pub type key_t = c_long;
1818

1919
#[cfg_attr(feature = "extra_traits", derive(Debug))]
20+
#[derive(Clone, Copy)]
2021
pub enum timezone {}
21-
impl Copy for timezone {}
22-
impl Clone for timezone {
23-
fn clone(&self) -> timezone {
24-
*self
25-
}
26-
}
22+
2723
#[cfg_attr(feature = "extra_traits", derive(Debug))]
24+
#[derive(Clone, Copy)]
2825
pub enum sem {}
29-
impl Copy for sem {}
30-
impl Clone for sem {
31-
fn clone(&self) -> sem {
32-
*self
33-
}
34-
}
3526

3627
s! {
3728
pub struct sched_param {

0 commit comments

Comments
 (0)