diff --git a/Cargo.toml b/Cargo.toml index 90088f43f12fd..0b18f4b7d1537 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -185,12 +185,15 @@ unused_qualifications = "allow" # We are okay with the current state of these lints explicit_iter_loop = "warn" +borrow_as_ptr = "warn" identity_op = "allow" # some expressions like `0 | x` are clearer for bit ops manual_assert = "warn" map_unwrap_or = "warn" missing_safety_doc = "allow" # safety? in libc? seriously? non_minimal_cfg = "allow" # for some reason cfg_if! sometimes trigger this ptr_as_ptr = "warn" +ptr_cast_constness = "warn" +ref_as_ptr = "warn" unnecessary_semicolon = "warn" # FIXME(clippy): these should be fixed if possible diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 51abedcb8fc10..a2224673d3f84 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3050,14 +3050,12 @@ f! { let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; - () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); - () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { diff --git a/src/macros.rs b/src/macros.rs index 0149b1fd18466..9809007e9185e 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -389,7 +389,7 @@ macro_rules! offset_of { ($Ty:path, $field:ident) => {{ // Taken from bytemuck, avoids accidentally calling on deref #[allow(clippy::unneeded_field_pattern)] - let $Ty { $field: _, .. }; + let $Ty { .. }; let data = core::mem::MaybeUninit::<$Ty>::uninit(); let ptr = data.as_ptr(); // nested unsafe, see f! diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index 89a30a888a5b4..3d4fa289eb1de 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -1338,7 +1338,7 @@ pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; let size_of_mask = size_of_val(&cpuset.bits[0]); - for i in cpuset.bits[..(size / size_of_mask)].iter() { + for i in &cpuset.bits[..(size / size_of_mask)] { s += i.count_ones(); } s as c_int diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 386da7de3279d..5aec1e8e25156 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1176,7 +1176,7 @@ const fn _CMSG_ALIGN(n: usize) -> usize { f! { pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(_CMSG_ALIGN(size_of::()) as isize) + (cmsg as *mut c_uchar).add(_CMSG_ALIGN(size_of::())) } pub const fn CMSG_LEN(length: c_uint) -> c_uint { @@ -1206,13 +1206,11 @@ f! { pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { let (idx, offset) = ((cpu >> 6) & 3, cpu & 63); cpuset.ary[idx] |= 1 << offset; - () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { let (idx, offset) = ((cpu >> 6) & 3, cpu & 63); cpuset.ary[idx] &= !(1 << offset); - () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 3a3f8076bb51e..76a142120998a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4238,19 +4238,19 @@ f! { } pub fn CPU_SET(cpu: usize, cpuset: &mut cpuset_t) -> () { - let bitset_bits = 8 * size_of::(); + let bitset_bits = c_long::BITS as usize; let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); cpuset.__bits[idx] |= 1 << offset; } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpuset_t) -> () { - let bitset_bits = 8 * size_of::(); + let bitset_bits = c_long::BITS as usize; let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); cpuset.__bits[idx] &= !(1 << offset); } pub fn CPU_ISSET(cpu: usize, cpuset: &cpuset_t) -> bool { - let bitset_bits = 8 * size_of::(); + let bitset_bits = c_long::BITS as usize; let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); 0 != cpuset.__bits[idx] & (1 << offset) } @@ -4260,7 +4260,7 @@ f! { let cpuset_size = size_of::(); let bitset_size = size_of::(); - for i in cpuset.__bits[..(cpuset_size / bitset_size)].iter() { + for i in &cpuset.__bits[..(cpuset_size / bitset_size)] { s += i.count_ones(); } s as c_int diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 50e45dbebe737..ba175c8378b1c 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1330,20 +1330,20 @@ cfg_if! { ptm_pad1: Padding::new([0; 3]), ptm_unused: Padding::new(0), ptm_pad2: Padding::new([0; 3]), - ptm_waiters: 0 as *mut _, + ptm_waiters: ptr::null_mut(), ptm_owner: 0, ptm_recursed: 0, - ptm_spare2: 0 as *mut _, + ptm_spare2: ptr::null_mut(), }; } else { pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { ptm_magic: 0x33330003, ptm_errorcheck: 0, ptm_unused: Padding::new(0), - ptm_waiters: 0 as *mut _, + ptm_waiters: ptr::null_mut(), ptm_owner: 0, ptm_recursed: 0, - ptm_spare2: 0 as *mut _, + ptm_spare2: ptr::null_mut(), }; } } @@ -1351,21 +1351,21 @@ cfg_if! { pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { ptc_magic: 0x55550005, ptc_lock: 0, - ptc_waiters_first: 0 as *mut _, - ptc_waiters_last: 0 as *mut _, - ptc_mutex: 0 as *mut _, - ptc_private: 0 as *mut _, + ptc_waiters_first: ptr::null_mut(), + ptc_waiters_last: ptr::null_mut(), + ptc_mutex: ptr::null_mut(), + ptc_private: ptr::null_mut(), }; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { ptr_magic: 0x99990009, ptr_interlock: 0, - ptr_rblocked_first: 0 as *mut _, - ptr_rblocked_last: 0 as *mut _, - ptr_wblocked_first: 0 as *mut _, - ptr_wblocked_last: 0 as *mut _, + ptr_rblocked_first: ptr::null_mut(), + ptr_rblocked_last: ptr::null_mut(), + ptr_wblocked_first: ptr::null_mut(), + ptr_wblocked_last: ptr::null_mut(), ptr_nreaders: 0, ptr_owner: 0, - ptr_private: 0 as *mut _, + ptr_private: ptr::null_mut(), }; pub const PTHREAD_MUTEX_NORMAL: c_int = 0; pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index e642ef18ebc27..810ac40ce0b80 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1822,7 +1822,7 @@ const fn _ALIGN(p: usize) -> usize { f! { pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(_ALIGN(size_of::()) as isize) + (cmsg as *mut c_uchar).add(_ALIGN(size_of::())) } pub const fn CMSG_LEN(length: c_uint) -> c_uint { diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 56ee0a5d105e7..8f38a099e23a6 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -1703,7 +1703,7 @@ f! { pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; let size_of_mask = size_of_val(&cpuset.bits[0]); - for i in cpuset.bits[..(size / size_of_mask)].iter() { + for i in &cpuset.bits[..(size / size_of_mask)] { s += i.count_ones(); } s as c_int @@ -1827,7 +1827,7 @@ safe_f! { } const fn CMSG_ALIGN(len: usize) -> usize { - len + size_of::() - 1 & !(size_of::() - 1) + (len + size_of::() - 1) & !(size_of::() - 1) } extern "C" { diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 8fae6f704d357..d5fe12af46e59 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1097,7 +1097,7 @@ pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { flags: 0, unused: Padding::new(0), - mutex: 0 as *mut _, + mutex: ptr::null_mut(), waiter_count: 0, lock: 0, }; @@ -1108,7 +1108,7 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { lock_count: 0, reader_count: 0, writer_count: 0, - waiters: [0 as *mut _; 2], + waiters: [ptr::null_mut(); 2], }; pub const PTHREAD_MUTEX_DEFAULT: c_int = 0; @@ -1377,7 +1377,7 @@ pub const POSIX_SPAWN_SETSIGMASK: c_short = 0x20; pub const POSIX_SPAWN_SETSID: c_short = 0x40; const fn CMSG_ALIGN(len: usize) -> usize { - len + size_of::() - 1 & !(size_of::() - 1) + (len + size_of::() - 1) & !(size_of::() - 1) } f! { @@ -1390,7 +1390,7 @@ f! { } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::()) as isize) + (cmsg as *mut c_uchar).add(CMSG_ALIGN(size_of::())) } pub const fn CMSG_SPACE(length: c_uint) -> c_uint { diff --git a/src/unix/haiku/native.rs b/src/unix/haiku/native.rs index 99ceab8a7519b..e41512f9d6102 100644 --- a/src/unix/haiku/native.rs +++ b/src/unix/haiku/native.rs @@ -650,7 +650,7 @@ pub const B_DIRECTORY_NODE: u32 = 0x04; pub const B_ANY_NODE: u32 = 0x07; // support/Errors.h -pub const B_GENERAL_ERROR_BASE: status_t = core::i32::MIN; +pub const B_GENERAL_ERROR_BASE: status_t = i32::MIN; pub const B_OS_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x1000; pub const B_APP_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x2000; pub const B_INTERFACE_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x3000; diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index af86822c634b3..884597d03bf5f 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -2057,7 +2057,7 @@ pub const S_IPTRANS: mode_t = 0o1000_0000; pub const S_IATRANS: mode_t = 0o2000_0000; pub const S_IROOT: mode_t = 0o4000_0000; pub const S_ITRANS: mode_t = 0o7000_0000; -pub const S_IMMAP0: mode_t = 0o10000_0000; +pub const S_IMMAP0: mode_t = 0o1_0000_0000; pub const CMASK: mode_t = 18; pub const UF_SETTABLE: c_uint = 65535; pub const UF_NODUMP: c_uint = 1; @@ -3336,19 +3336,19 @@ pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { }; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { __lock: __PTHREAD_SPIN_LOCK_INITIALIZER, - __queue: 0i64 as *mut __pthread, - __attr: 0i64 as *mut __pthread_condattr, + __queue: ptr::null_mut::<__pthread>(), + __attr: ptr::null_mut::<__pthread_condattr>(), __wrefs: 0, - __data: 0i64 as *mut c_void, + __data: ptr::null_mut::(), }; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __held: __PTHREAD_SPIN_LOCK_INITIALIZER, __lock: __PTHREAD_SPIN_LOCK_INITIALIZER, __readers: 0, - __readerqueue: 0i64 as *mut __pthread, - __writerqueue: 0i64 as *mut __pthread, - __attr: 0i64 as *mut __pthread_rwlockattr, - __data: 0i64 as *mut c_void, + __readerqueue: ptr::null_mut::<__pthread>(), + __writerqueue: ptr::null_mut::<__pthread>(), + __attr: ptr::null_mut::<__pthread_rwlockattr>(), + __data: ptr::null_mut::(), }; pub const PTHREAD_STACK_MIN: size_t = 0; @@ -3365,12 +3365,12 @@ f! { if (*mhdr).msg_controllen as usize >= size_of::() { (*mhdr).msg_control.cast::() } else { - core::ptr::null_mut::() + ptr::null_mut::() } } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::()) as isize) + (cmsg as *mut c_uchar).add(CMSG_ALIGN(size_of::())) } pub const fn CMSG_SPACE(length: c_uint) -> c_uint { @@ -3383,14 +3383,14 @@ f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if ((*cmsg).cmsg_len as usize) < size_of::() { - return core::ptr::null_mut::(); + return ptr::null_mut::(); } let next = (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if (next.offset(1)) as usize > max || next as usize + CMSG_ALIGN((*next).cmsg_len as usize) > max { - core::ptr::null_mut::() + ptr::null_mut::() } else { next.cast::() } @@ -3427,7 +3427,7 @@ f! { pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; let size_of_mask = size_of_val(&cpuset.bits[0]); - for i in cpuset.bits[..(size / size_of_mask)].iter() { + for i in &cpuset.bits[..(size / size_of_mask)] { s += i.count_ones(); } s as c_int diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 6a2f1bcf8cf51..24905e17b53c9 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3303,14 +3303,12 @@ f! { let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.__bits[idx] |= 1 << offset; - () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.__bits[idx] &= !(1 << offset); - () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { @@ -3322,7 +3320,7 @@ f! { pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; let size_of_mask = size_of_val(&cpuset.__bits[0]); - for i in cpuset.__bits[..(size / size_of_mask)].iter() { + for i in &cpuset.__bits[..(size / size_of_mask)] { s += i.count_ones(); } s as c_int diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index a97e772f99e75..53b118dcf5c8c 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1272,14 +1272,12 @@ f! { let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; - () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); - () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index 6b320ff4effa2..e20c9f8a7047c 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -1512,7 +1512,7 @@ f! { if next_cmsg as usize + size_of::() > max_addr { core::ptr::null_mut::() } else { - next_cmsg as *mut crate::cmsghdr + next_cmsg.cast_mut() } } diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 082e48739fe35..5ee9d25f83cf3 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -2417,7 +2417,7 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { }; const fn _CMSG_ALIGN(len: usize) -> usize { - len + size_of::() - 1 & !(size_of::() - 1) + (len + size_of::() - 1) & !(size_of::() - 1) } const fn _ALIGN(p: usize, b: usize) -> usize { @@ -2444,7 +2444,7 @@ f! { } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(_CMSG_ALIGN(size_of::()) as isize) + (cmsg as *mut c_uchar).add(_CMSG_ALIGN(size_of::())) } pub const fn CMSG_LEN(length: c_uint) -> c_uint { @@ -2480,7 +2480,7 @@ f! { } pub fn _DEXTRA_FIRST(_d: *const dirent) -> *mut crate::dirent_extra { - let _f = &((*(_d)).d_name) as *const _; + let _f = core::ptr::addr_of!(((*(_d)).d_name)); let _s = _d as usize; _ALIGN(_s + _f as usize - _s + (*_d).d_namelen as usize + 1, 8) as *mut crate::dirent_extra @@ -2490,11 +2490,7 @@ f! { let sz = _x as usize - _d as usize + size_of::(); let rsz = (*_d).d_reclen as usize; - if sz > rsz || sz + (*_x).d_datalen as usize > rsz { - false - } else { - true - } + !(sz > rsz || sz + (*_x).d_datalen as usize > rsz) } pub fn _DEXTRA_NEXT(_x: *const crate::dirent_extra) -> *mut crate::dirent_extra { @@ -3145,7 +3141,7 @@ pub unsafe fn atexit(cb: extern "C" fn()) -> c_int { static __dso_handle: *mut c_void; pub fn __cxa_atexit(cb: extern "C" fn(), __arg: *mut c_void, __dso: *mut c_void) -> c_int; } - __cxa_atexit(cb, 0 as *mut c_void, __dso_handle) + __cxa_atexit(cb, core::ptr::null_mut::(), __dso_handle) } impl siginfo_t { diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index ffcc87cba0727..733ed7a2012b5 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -705,7 +705,7 @@ s_no_extra_traits! { impl siginfo_t { unsafe fn sidata(&self) -> T { - *((&self.__data_pad) as *const c_int as *const T) + *core::ptr::addr_of!(self.__data_pad).cast() } pub unsafe fn si_addr(&self) -> *mut c_void { let sifault: siginfo_fault = self.sidata(); diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 00428543d7aff..e5113aa198c8a 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1441,7 +1441,7 @@ extern_ty! { f! { pub const fn CMSG_ALIGN(len: usize) -> usize { - len + size_of::() - 1 & !(size_of::() - 1) + (len + size_of::() - 1) & !(size_of::() - 1) } pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { @@ -1465,7 +1465,7 @@ f! { } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::()) as isize) + (cmsg as *mut c_uchar).add(CMSG_ALIGN(size_of::())) } pub const fn CMSG_SPACE(length: c_uint) -> c_uint { @@ -2427,7 +2427,7 @@ pub unsafe fn pwrite(_fd: c_int, _buf: *const c_void, _count: size_t, _offset: o pub unsafe fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int { // check to see if align is a power of 2 and if align is a multiple // of sizeof(void *) - if (align & align - 1 != 0) || (align as usize % size_of::() != 0) { + if (align & (align - 1) != 0) || (align as usize % size_of::() != 0) { return crate::EINVAL; } diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index 2e4a6bded49d2..305d976394600 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -3,8 +3,6 @@ //! `wasi-libc` project provides multiple libraries including emulated features, but we list only //! basic features with `libc.a` here. -use core::iter::Iterator; - use crate::prelude::*; pub type intmax_t = i64; @@ -622,13 +620,13 @@ f! { pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let set = &*set; let n = set.__nfds; - return set.__fds[..n].iter().any(|p| *p == fd); + return set.__fds[..n].contains(&fd); } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let set = &mut *set; let n = set.__nfds; - if !set.__fds[..n].iter().any(|p| *p == fd) { + if !set.__fds[..n].contains(&fd) { set.__nfds = n + 1; set.__fds[n] = fd; }