From b2532cb3b868ff35251c21252769092789b7cb08 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sun, 19 Jan 2025 12:08:33 +0800 Subject: [PATCH] Clippy fixes --- src/krate_name.rs | 7 ++++--- src/utils/flock/unix.rs | 4 ++-- src/utils/git.rs | 11 ++++------- tests/flock.rs | 2 ++ tests/git.rs | 1 + tests/local.rs | 1 + tests/sparse.rs | 2 ++ tests/utils.rs | 1 + 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/krate_name.rs b/src/krate_name.rs index fe957dc..ae02fcc 100644 --- a/src/krate_name.rs +++ b/src/krate_name.rs @@ -1,6 +1,7 @@ use crate::error::{Error, InvalidKrateName}; #[cfg(test)] +/// Create a `KrateName` from a string literal. #[macro_export] macro_rules! kn { ($kn:literal) => { @@ -200,7 +201,7 @@ impl<'name> TryFrom<&'name str> for KrateName<'name> { } } -impl<'name> KrateName<'name> { +impl KrateName<'_> { /// Writes the crate's prefix to the specified string /// /// Cargo uses a simple prefix in the registry index so that crate's can be @@ -259,14 +260,14 @@ impl<'name> KrateName<'name> { use std::fmt; -impl<'k> fmt::Display for KrateName<'k> { +impl fmt::Display for KrateName<'_> { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.0) } } -impl<'k> fmt::Debug for KrateName<'k> { +impl fmt::Debug for KrateName<'_> { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.0) diff --git a/src/utils/flock/unix.rs b/src/utils/flock/unix.rs index 2809105..8ea81e5 100644 --- a/src/utils/flock/unix.rs +++ b/src/utils/flock/unix.rs @@ -146,10 +146,10 @@ pub(super) fn is_unsupported(err: &std::io::Error) -> bool { #[inline] pub(super) fn is_contended(err: &Error) -> bool { - err.raw_os_error().map_or(false, |x| x == libc::EWOULDBLOCK) + err.raw_os_error() == Some(libc::EWOULDBLOCK) } #[inline] pub(super) fn is_timed_out(err: &Error) -> bool { - err.raw_os_error().map_or(false, |x| x == libc::EINTR) + err.raw_os_error() == Some(libc::EINTR) } diff --git a/src/utils/git.rs b/src/utils/git.rs index 3df27f4..54ff56b 100644 --- a/src/utils/git.rs +++ b/src/utils/git.rs @@ -93,13 +93,10 @@ pub fn write_fetch_head( } rspec.local().map_or(false, |l| { - l.to_str() - .ok() - .and_then(|l| { - l.strip_prefix("refs/remotes/") - .and_then(|l| l.strip_suffix("/HEAD")) - }) - .map_or(false, |remote| remote == remote_name) + l.to_str().ok().and_then(|l| { + l.strip_prefix("refs/remotes/") + .and_then(|l| l.strip_suffix("/HEAD")) + }) == Some(remote_name) }) }) { diff --git a/tests/flock.rs b/tests/flock.rs index a813769..decd73d 100644 --- a/tests/flock.rs +++ b/tests/flock.rs @@ -1,3 +1,5 @@ +#![allow(missing_docs)] + use std::time::Duration; use tame_index::utils::flock::LockOptions; diff --git a/tests/git.rs b/tests/git.rs index e741fe3..fa7d5c0 100644 --- a/tests/git.rs +++ b/tests/git.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(feature = "__git")] mod utils; diff --git a/tests/local.rs b/tests/local.rs index 3569144..d9a9ec0 100644 --- a/tests/local.rs +++ b/tests/local.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] #![cfg(all(feature = "local-builder", feature = "sparse"))] mod utils; diff --git a/tests/sparse.rs b/tests/sparse.rs index 332b70b..183814a 100644 --- a/tests/sparse.rs +++ b/tests/sparse.rs @@ -1,3 +1,5 @@ +#![allow(missing_docs)] + mod utils; use http::header; diff --git a/tests/utils.rs b/tests/utils.rs index 9cabc3a..775771b 100644 --- a/tests/utils.rs +++ b/tests/utils.rs @@ -1,4 +1,5 @@ #![allow(dead_code)] +#![allow(missing_docs)] pub use tame_index::{IndexKrate, Path, PathBuf};