Skip to content

Commit c003ae9

Browse files
authored
refactor: fix clippy & unused imports/helper type (#2416)
1 parent 1dad4d8 commit c003ae9

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub type Result<T> = result::Result<T, Errno>;
205205
/// * `Eq`
206206
/// * Small size
207207
/// * Represents all of the system's errnos, instead of just the most common
208-
/// ones.
208+
/// ones.
209209
pub type Error = Errno;
210210

211211
/// Common trait used to represent file system paths by many Nix functions.

src/sched.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ mod sched_linux_like {
120120
let ptr = stack.as_mut_ptr().add(stack.len());
121121
let ptr_aligned = ptr.sub(ptr as usize % 16);
122122
libc::clone(
123-
mem::transmute(
123+
mem::transmute::<
124+
extern "C" fn(*mut Box<dyn FnMut() -> isize>) -> i32,
125+
extern "C" fn(*mut libc::c_void) -> i32,
126+
>(
124127
callback
125128
as extern "C" fn(*mut Box<dyn FnMut() -> isize>) -> i32,
126129
),

src/sys/socket/sockopt.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ use crate::sys::time::TimeVal;
55
use crate::Result;
66
use cfg_if::cfg_if;
77
use libc::{self, c_int, c_void, socklen_t};
8-
use std::ffi::{CStr, CString, OsStr, OsString};
8+
#[cfg(apple_targets)]
9+
use std::ffi::{CStr, CString};
10+
#[cfg(any(target_os = "freebsd", linux_android))]
11+
use std::ffi::{OsStr, OsString};
912
use std::mem::{self, MaybeUninit};
13+
#[cfg(any(target_os = "freebsd", linux_android))]
1014
use std::os::unix::ffi::OsStrExt;
1115
use std::os::unix::io::{AsFd, AsRawFd};
1216

@@ -749,7 +753,12 @@ sockopt_impl!(
749753
libc::SO_TIMESTAMPING,
750754
super::TimestampingFlag
751755
);
752-
#[cfg(not(any(target_os = "aix", target_os = "haiku", target_os = "hurd", target_os = "redox")))]
756+
#[cfg(not(any(
757+
target_os = "aix",
758+
target_os = "haiku",
759+
target_os = "hurd",
760+
target_os = "redox"
761+
)))]
753762
sockopt_impl!(
754763
/// Enable or disable the receiving of the `SO_TIMESTAMP` control message.
755764
ReceiveTimestamp,
@@ -1300,7 +1309,6 @@ impl SetSockOpt for TcpTlsRx {
13001309
}
13011310
}
13021311

1303-
13041312
/*
13051313
*
13061314
* ===== Accessor helpers =====
@@ -1438,11 +1446,13 @@ impl<'a> Set<'a, bool> for SetBool {
14381446
}
14391447

14401448
/// Getter for an `u8` value.
1449+
#[cfg(feature = "net")]
14411450
struct GetU8 {
14421451
len: socklen_t,
14431452
val: MaybeUninit<u8>,
14441453
}
14451454

1455+
#[cfg(feature = "net")]
14461456
impl Get<u8> for GetU8 {
14471457
fn uninit() -> Self {
14481458
GetU8 {
@@ -1470,10 +1480,12 @@ impl Get<u8> for GetU8 {
14701480
}
14711481

14721482
/// Setter for an `u8` value.
1483+
#[cfg(feature = "net")]
14731484
struct SetU8 {
14741485
val: u8,
14751486
}
14761487

1488+
#[cfg(feature = "net")]
14771489
impl<'a> Set<'a, u8> for SetU8 {
14781490
fn new(val: &'a u8) -> SetU8 {
14791491
SetU8 { val: *val }
@@ -1540,11 +1552,13 @@ impl<'a> Set<'a, usize> for SetUsize {
15401552
}
15411553

15421554
/// Getter for a `OsString` value.
1555+
#[cfg(any(target_os = "freebsd", linux_android))]
15431556
struct GetOsString<T: AsMut<[u8]>> {
15441557
len: socklen_t,
15451558
val: MaybeUninit<T>,
15461559
}
15471560

1561+
#[cfg(any(target_os = "freebsd", linux_android))]
15481562
impl<T: AsMut<[u8]>> Get<OsString> for GetOsString<T> {
15491563
fn uninit() -> Self {
15501564
GetOsString {
@@ -1569,10 +1583,12 @@ impl<T: AsMut<[u8]>> Get<OsString> for GetOsString<T> {
15691583
}
15701584

15711585
/// Setter for a `OsString` value.
1586+
#[cfg(any(target_os = "freebsd", linux_android))]
15721587
struct SetOsString<'a> {
15731588
val: &'a OsStr,
15741589
}
15751590

1591+
#[cfg(any(target_os = "freebsd", linux_android))]
15761592
impl<'a> Set<'a, OsString> for SetOsString<'a> {
15771593
fn new(val: &'a OsString) -> SetOsString {
15781594
SetOsString {
@@ -1590,11 +1606,13 @@ impl<'a> Set<'a, OsString> for SetOsString<'a> {
15901606
}
15911607

15921608
/// Getter for a `CString` value.
1609+
#[cfg(apple_targets)]
15931610
struct GetCString<T: AsMut<[u8]>> {
15941611
len: socklen_t,
15951612
val: MaybeUninit<T>,
15961613
}
15971614

1615+
#[cfg(apple_targets)]
15981616
impl<T: AsMut<[u8]>> Get<CString> for GetCString<T> {
15991617
fn uninit() -> Self {
16001618
GetCString {

src/sys/timer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl Timer {
9595
/// There are 3 types of alarms you can set:
9696
///
9797
/// - one shot: the alarm will trigger once after the specified amount of
98-
/// time.
98+
/// time.
9999
/// Example: I want an alarm to go off in 60s and then disable itself.
100100
///
101101
/// - interval: the alarm will trigger every specified interval of time.

src/sys/timerfd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl TimerFd {
113113
/// There are 3 types of alarms you can set:
114114
///
115115
/// - one shot: the alarm will trigger once after the specified amount of
116-
/// time.
116+
/// time.
117117
/// Example: I want an alarm to go off in 60s and then disable itself.
118118
///
119119
/// - interval: the alarm will trigger every specified interval of time.

0 commit comments

Comments
 (0)