Skip to content

Commit

Permalink
Fix some clippy::needless_lifetime lints (#2519)
Browse files Browse the repository at this point in the history
  • Loading branch information
asomers authored Oct 11, 2024
1 parent 9064b4c commit 15db1fd
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ fn next(dir: &mut Dir) -> Option<Result<Entry>> {
#[derive(Debug, Eq, Hash, PartialEq)]
pub struct Iter<'d>(&'d mut Dir);

impl<'d> Iterator for Iter<'d> {
impl Iterator for Iter<'_> {
type Item = Result<Entry>;

fn next(&mut self) -> Option<Self::Item> {
next(self.0)
}
}

impl<'d> Drop for Iter<'d> {
impl Drop for Iter<'_> {
fn drop(&mut self) {
unsafe { libc::rewinddir((self.0).0.as_ptr()) }
}
Expand Down
2 changes: 1 addition & 1 deletion src/mount/bsd_without_apple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ impl<'a> Nmount<'a> {
}

#[cfg(target_os = "freebsd")]
impl<'a> Drop for Nmount<'a> {
impl Drop for Nmount<'_> {
fn drop(&mut self) {
for (iov, is_owned) in self.iov.iter().zip(self.is_owned.iter()) {
if *is_owned {
Expand Down
2 changes: 1 addition & 1 deletion src/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<'fd> PollFd<'fd> {
}
}

impl<'fd> AsFd for PollFd<'fd> {
impl AsFd for PollFd<'_> {
fn as_fd(&self) -> BorrowedFd<'_> {
// Safety:
//
Expand Down
22 changes: 11 additions & 11 deletions src/sys/aio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl<'a> AioCb<'a> {
}
}

impl<'a> Debug for AioCb<'a> {
impl Debug for AioCb<'_> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("AioCb")
.field("aiocb", &self.aiocb.0)
Expand All @@ -202,7 +202,7 @@ impl<'a> Debug for AioCb<'a> {
}
}

impl<'a> Drop for AioCb<'a> {
impl Drop for AioCb<'_> {
/// If the `AioCb` has no remaining state in the kernel, just drop it.
/// Otherwise, dropping constitutes a resource leak, which is an error
fn drop(&mut self) {
Expand Down Expand Up @@ -499,7 +499,7 @@ impl<'a> Aio for AioFsync<'a> {

// AioFsync does not need AsMut, since it can't be used with lio_listio

impl<'a> AsRef<libc::aiocb> for AioFsync<'a> {
impl AsRef<libc::aiocb> for AioFsync<'_> {
fn as_ref(&self) -> &libc::aiocb {
&self.aiocb.aiocb.0
}
Expand Down Expand Up @@ -609,13 +609,13 @@ impl<'a> Aio for AioRead<'a> {
aio_methods!(aio_read);
}

impl<'a> AsMut<libc::aiocb> for AioRead<'a> {
impl AsMut<libc::aiocb> for AioRead<'_> {
fn as_mut(&mut self) -> &mut libc::aiocb {
&mut self.aiocb.aiocb.0
}
}

impl<'a> AsRef<libc::aiocb> for AioRead<'a> {
impl AsRef<libc::aiocb> for AioRead<'_> {
fn as_ref(&self) -> &libc::aiocb {
&self.aiocb.aiocb.0
}
Expand Down Expand Up @@ -732,14 +732,14 @@ impl<'a> Aio for AioReadv<'a> {
}

#[cfg(target_os = "freebsd")]
impl<'a> AsMut<libc::aiocb> for AioReadv<'a> {
impl AsMut<libc::aiocb> for AioReadv<'_> {
fn as_mut(&mut self) -> &mut libc::aiocb {
&mut self.aiocb.aiocb.0
}
}

#[cfg(target_os = "freebsd")]
impl<'a> AsRef<libc::aiocb> for AioReadv<'a> {
impl AsRef<libc::aiocb> for AioReadv<'_> {
fn as_ref(&self) -> &libc::aiocb {
&self.aiocb.aiocb.0
}
Expand Down Expand Up @@ -845,13 +845,13 @@ impl<'a> Aio for AioWrite<'a> {
aio_methods!(aio_write);
}

impl<'a> AsMut<libc::aiocb> for AioWrite<'a> {
impl AsMut<libc::aiocb> for AioWrite<'_> {
fn as_mut(&mut self) -> &mut libc::aiocb {
&mut self.aiocb.aiocb.0
}
}

impl<'a> AsRef<libc::aiocb> for AioWrite<'a> {
impl AsRef<libc::aiocb> for AioWrite<'_> {
fn as_ref(&self) -> &libc::aiocb {
&self.aiocb.aiocb.0
}
Expand Down Expand Up @@ -965,14 +965,14 @@ impl<'a> Aio for AioWritev<'a> {
}

#[cfg(target_os = "freebsd")]
impl<'a> AsMut<libc::aiocb> for AioWritev<'a> {
impl AsMut<libc::aiocb> for AioWritev<'_> {
fn as_mut(&mut self) -> &mut libc::aiocb {
&mut self.aiocb.aiocb.0
}
}

#[cfg(target_os = "freebsd")]
impl<'a> AsRef<libc::aiocb> for AioWritev<'a> {
impl AsRef<libc::aiocb> for AioWritev<'_> {
fn as_ref(&self) -> &libc::aiocb {
&self.aiocb.aiocb.0
}
Expand Down
8 changes: 4 additions & 4 deletions src/sys/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl<'fd> FdSet<'fd> {
}
}

impl<'fd> Default for FdSet<'fd> {
impl Default for FdSet<'_> {
fn default() -> Self {
Self::new()
}
Expand All @@ -128,7 +128,7 @@ pub struct Fds<'a, 'fd> {
range: Range<usize>,
}

impl<'a, 'fd> Iterator for Fds<'a, 'fd> {
impl<'fd> Iterator for Fds<'_, 'fd> {
type Item = BorrowedFd<'fd>;

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -148,7 +148,7 @@ impl<'a, 'fd> Iterator for Fds<'a, 'fd> {
}
}

impl<'a, 'fd> DoubleEndedIterator for Fds<'a, 'fd> {
impl<'fd> DoubleEndedIterator for Fds<'_, 'fd> {
#[inline]
fn next_back(&mut self) -> Option<BorrowedFd<'fd>> {
while let Some(i) = self.range.next_back() {
Expand All @@ -161,7 +161,7 @@ impl<'a, 'fd> DoubleEndedIterator for Fds<'a, 'fd> {
}
}

impl<'a, 'fd> FusedIterator for Fds<'a, 'fd> {}
impl FusedIterator for Fds<'_, '_> {}

/// Monitors file descriptors for readiness
///
Expand Down
2 changes: 1 addition & 1 deletion src/sys/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ mod sigevent {
}
}

impl<'a> From<&'a libc::sigevent> for SigEvent {
impl From<&'_ libc::sigevent> for SigEvent {
#[cfg(target_os = "freebsd")]
fn from(sigevent: &libc::sigevent) -> Self {
// Safe because they're really the same structure. See
Expand Down
6 changes: 3 additions & 3 deletions src/sys/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ pub struct RecvMsg<'a, 's, S> {
mhdr: msghdr,
}

impl<'a, S> RecvMsg<'a, '_, S> {
impl<S> RecvMsg<'_, '_, S> {
/// Iterate over the valid control messages pointed to by this msghdr. If
/// allocated space for CMSGs was too small it is not safe to iterate,
/// instead return an `Error::ENOBUFS` error.
Expand All @@ -623,7 +623,7 @@ pub struct CmsgIterator<'a> {
mhdr: &'a msghdr
}

impl<'a> Iterator for CmsgIterator<'a> {
impl Iterator for CmsgIterator<'_> {
type Item = ControlMessageOwned;

fn next(&mut self) -> Option<ControlMessageOwned> {
Expand Down Expand Up @@ -1260,7 +1260,7 @@ pub enum ControlMessage<'a> {
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct UnknownCmsg(cmsghdr, Vec<u8>);

impl<'a> ControlMessage<'a> {
impl ControlMessage<'_> {
/// The value of CMSG_SPACE on this message.
/// Safe because CMSG_SPACE is always safe
fn space(&self) -> usize {
Expand Down
4 changes: 2 additions & 2 deletions test/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct DirRestore<'a> {
_g: RwLockWriteGuard<'a, ()>,
}

impl<'a> DirRestore<'a> {
impl DirRestore<'_> {
fn new() -> Self {
let guard = crate::CWD_LOCK.write();
DirRestore {
Expand All @@ -95,7 +95,7 @@ impl<'a> DirRestore<'a> {
}
}

impl<'a> Drop for DirRestore<'a> {
impl Drop for DirRestore<'_> {
fn drop(&mut self) {
let r = chdir(&self.d);
if std::thread::panicking() {
Expand Down

0 comments on commit 15db1fd

Please sign in to comment.