Rollup merge of #130115 - eduardosm:needless-returns-libs, r=workingjubilee
Remove needless returns detected by clippy in libraries
This commit is contained in:
commit
2f1cf6feb0
@ -73,7 +73,7 @@ impl<'a, T> Iterator for Iter<'a, T> {
|
|||||||
fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
|
fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
|
||||||
let remaining = self.i1.advance_by(n);
|
let remaining = self.i1.advance_by(n);
|
||||||
match remaining {
|
match remaining {
|
||||||
Ok(()) => return Ok(()),
|
Ok(()) => Ok(()),
|
||||||
Err(n) => {
|
Err(n) => {
|
||||||
mem::swap(&mut self.i1, &mut self.i2);
|
mem::swap(&mut self.i1, &mut self.i2);
|
||||||
self.i1.advance_by(n.get())
|
self.i1.advance_by(n.get())
|
||||||
@ -144,7 +144,7 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
|
|||||||
|
|
||||||
fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
|
fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
|
||||||
match self.i2.advance_back_by(n) {
|
match self.i2.advance_back_by(n) {
|
||||||
Ok(()) => return Ok(()),
|
Ok(()) => Ok(()),
|
||||||
Err(n) => {
|
Err(n) => {
|
||||||
mem::swap(&mut self.i1, &mut self.i2);
|
mem::swap(&mut self.i1, &mut self.i2);
|
||||||
self.i2.advance_back_by(n.get())
|
self.i2.advance_back_by(n.get())
|
||||||
|
@ -64,7 +64,7 @@ impl<'a, T> Iterator for IterMut<'a, T> {
|
|||||||
|
|
||||||
fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
|
fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
|
||||||
match self.i1.advance_by(n) {
|
match self.i1.advance_by(n) {
|
||||||
Ok(()) => return Ok(()),
|
Ok(()) => Ok(()),
|
||||||
Err(remaining) => {
|
Err(remaining) => {
|
||||||
mem::swap(&mut self.i1, &mut self.i2);
|
mem::swap(&mut self.i1, &mut self.i2);
|
||||||
self.i1.advance_by(remaining.get())
|
self.i1.advance_by(remaining.get())
|
||||||
@ -135,7 +135,7 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
|
|||||||
|
|
||||||
fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
|
fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
|
||||||
match self.i2.advance_back_by(n) {
|
match self.i2.advance_back_by(n) {
|
||||||
Ok(()) => return Ok(()),
|
Ok(()) => Ok(()),
|
||||||
Err(remaining) => {
|
Err(remaining) => {
|
||||||
mem::swap(&mut self.i1, &mut self.i2);
|
mem::swap(&mut self.i1, &mut self.i2);
|
||||||
self.i2.advance_back_by(remaining.get())
|
self.i2.advance_back_by(remaining.get())
|
||||||
|
@ -208,7 +208,7 @@ const fn needs_realloc<SRC, DEST>(src_cap: usize, dst_cap: usize) -> bool {
|
|||||||
|
|
||||||
// type layouts don't guarantee a fit, so do a runtime check to see if
|
// type layouts don't guarantee a fit, so do a runtime check to see if
|
||||||
// the allocations happen to match
|
// the allocations happen to match
|
||||||
return src_cap > 0 && src_cap * mem::size_of::<SRC>() != dst_cap * mem::size_of::<DEST>();
|
src_cap > 0 && src_cap * mem::size_of::<SRC>() != dst_cap * mem::size_of::<DEST>()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This provides a shorthand for the source type since local type aliases aren't a thing.
|
/// This provides a shorthand for the source type since local type aliases aren't a thing.
|
||||||
|
@ -288,11 +288,11 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
|
|||||||
|
|
||||||
// Safety: `len` is larger than the array size. Copy a fixed amount here to fully initialize
|
// Safety: `len` is larger than the array size. Copy a fixed amount here to fully initialize
|
||||||
// the array.
|
// the array.
|
||||||
return unsafe {
|
unsafe {
|
||||||
ptr::copy_nonoverlapping(self.ptr.as_ptr(), raw_ary.as_mut_ptr() as *mut T, N);
|
ptr::copy_nonoverlapping(self.ptr.as_ptr(), raw_ary.as_mut_ptr() as *mut T, N);
|
||||||
self.ptr = self.ptr.add(N);
|
self.ptr = self.ptr.add(N);
|
||||||
Ok(raw_ary.transpose().assume_init())
|
Ok(raw_ary.transpose().assume_init())
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold<B, F>(mut self, mut accum: B, mut f: F) -> B
|
fn fold<B, F>(mut self, mut accum: B, mut f: F) -> B
|
||||||
|
@ -187,14 +187,14 @@ impl<Dyn: ?Sized> DynMetadata<Dyn> {
|
|||||||
// Consider a reference like `&(i32, dyn Send)`: the vtable will only store the size of the
|
// Consider a reference like `&(i32, dyn Send)`: the vtable will only store the size of the
|
||||||
// `Send` part!
|
// `Send` part!
|
||||||
// SAFETY: DynMetadata always contains a valid vtable pointer
|
// SAFETY: DynMetadata always contains a valid vtable pointer
|
||||||
return unsafe { crate::intrinsics::vtable_size(self.vtable_ptr() as *const ()) };
|
unsafe { crate::intrinsics::vtable_size(self.vtable_ptr() as *const ()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the alignment of the type associated with this vtable.
|
/// Returns the alignment of the type associated with this vtable.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn align_of(self) -> usize {
|
pub fn align_of(self) -> usize {
|
||||||
// SAFETY: DynMetadata always contains a valid vtable pointer
|
// SAFETY: DynMetadata always contains a valid vtable pointer
|
||||||
return unsafe { crate::intrinsics::vtable_align(self.vtable_ptr() as *const ()) };
|
unsafe { crate::intrinsics::vtable_align(self.vtable_ptr() as *const ()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the size and alignment together as a `Layout`
|
/// Returns the size and alignment together as a `Layout`
|
||||||
|
@ -1814,7 +1814,7 @@ fn simd_contains(needle: &str, haystack: &str) -> Option<bool> {
|
|||||||
}
|
}
|
||||||
mask &= !(1 << trailing);
|
mask &= !(1 << trailing);
|
||||||
}
|
}
|
||||||
return false;
|
false
|
||||||
};
|
};
|
||||||
|
|
||||||
let test_chunk = |idx| -> u16 {
|
let test_chunk = |idx| -> u16 {
|
||||||
@ -1830,7 +1830,7 @@ fn simd_contains(needle: &str, haystack: &str) -> Option<bool> {
|
|||||||
let both = eq_first.bitand(eq_last);
|
let both = eq_first.bitand(eq_last);
|
||||||
let mask = both.to_bitmask() as u16;
|
let mask = both.to_bitmask() as u16;
|
||||||
|
|
||||||
return mask;
|
mask
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
|
@ -13,7 +13,7 @@ pub(crate) struct PidFd(FileDesc);
|
|||||||
|
|
||||||
impl PidFd {
|
impl PidFd {
|
||||||
pub fn kill(&self) -> io::Result<()> {
|
pub fn kill(&self) -> io::Result<()> {
|
||||||
return cvt(unsafe {
|
cvt(unsafe {
|
||||||
libc::syscall(
|
libc::syscall(
|
||||||
libc::SYS_pidfd_send_signal,
|
libc::SYS_pidfd_send_signal,
|
||||||
self.0.as_raw_fd(),
|
self.0.as_raw_fd(),
|
||||||
@ -22,7 +22,7 @@ impl PidFd {
|
|||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.map(drop);
|
.map(drop)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wait(&self) -> io::Result<ExitStatus> {
|
pub fn wait(&self) -> io::Result<ExitStatus> {
|
||||||
@ -30,7 +30,7 @@ impl PidFd {
|
|||||||
cvt(unsafe {
|
cvt(unsafe {
|
||||||
libc::waitid(libc::P_PIDFD, self.0.as_raw_fd() as u32, &mut siginfo, libc::WEXITED)
|
libc::waitid(libc::P_PIDFD, self.0.as_raw_fd() as u32, &mut siginfo, libc::WEXITED)
|
||||||
})?;
|
})?;
|
||||||
return Ok(ExitStatus::from_waitid_siginfo(siginfo));
|
Ok(ExitStatus::from_waitid_siginfo(siginfo))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn try_wait(&self) -> io::Result<Option<ExitStatus>> {
|
pub fn try_wait(&self) -> io::Result<Option<ExitStatus>> {
|
||||||
@ -45,9 +45,10 @@ impl PidFd {
|
|||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
if unsafe { siginfo.si_pid() } == 0 {
|
if unsafe { siginfo.si_pid() } == 0 {
|
||||||
return Ok(None);
|
Ok(None)
|
||||||
|
} else {
|
||||||
|
Ok(Some(ExitStatus::from_waitid_siginfo(siginfo)))
|
||||||
}
|
}
|
||||||
return Ok(Some(ExitStatus::from_waitid_siginfo(siginfo)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ impl OpenOptions {
|
|||||||
pub fn new() -> OpenOptions {
|
pub fn new() -> OpenOptions {
|
||||||
let mut base = OpenOptions::default();
|
let mut base = OpenOptions::default();
|
||||||
base.dirflags = wasi::LOOKUPFLAGS_SYMLINK_FOLLOW;
|
base.dirflags = wasi::LOOKUPFLAGS_SYMLINK_FOLLOW;
|
||||||
return base;
|
base
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(&mut self, read: bool) {
|
pub fn read(&mut self, read: bool) {
|
||||||
@ -382,7 +382,7 @@ impl OpenOptions {
|
|||||||
base |= wasi::RIGHTS_PATH_UNLINK_FILE;
|
base |= wasi::RIGHTS_PATH_UNLINK_FILE;
|
||||||
base |= wasi::RIGHTS_POLL_FD_READWRITE;
|
base |= wasi::RIGHTS_POLL_FD_READWRITE;
|
||||||
|
|
||||||
return base;
|
base
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rights_inheriting(&self) -> wasi::Rights {
|
fn rights_inheriting(&self) -> wasi::Rights {
|
||||||
|
@ -115,7 +115,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {
|
|||||||
let len = mem::size_of_val(&ret);
|
let len = mem::size_of_val(&ret);
|
||||||
wasi::random_get(base, len).expect("random_get failure");
|
wasi::random_get(base, len).expect("random_get failure");
|
||||||
}
|
}
|
||||||
return ret;
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user