Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed Jan 19, 2025
1 parent c694f27 commit b2532cb
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/krate_name.rs
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/flock/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
11 changes: 4 additions & 7 deletions src/utils/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
{
Expand Down
2 changes: 2 additions & 0 deletions tests/flock.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(missing_docs)]

use std::time::Duration;
use tame_index::utils::flock::LockOptions;

Expand Down
1 change: 1 addition & 0 deletions tests/git.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(feature = "__git")]

mod utils;
Expand Down
1 change: 1 addition & 0 deletions tests/local.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
#![cfg(all(feature = "local-builder", feature = "sparse"))]

mod utils;
Expand Down
2 changes: 2 additions & 0 deletions tests/sparse.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(missing_docs)]

mod utils;

use http::header;
Expand Down
1 change: 1 addition & 0 deletions tests/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(dead_code)]
#![allow(missing_docs)]

pub use tame_index::{IndexKrate, Path, PathBuf};

Expand Down

0 comments on commit b2532cb

Please sign in to comment.