Skip to content

Commit

Permalink
Apply cargo clippy --fix
Browse files Browse the repository at this point in the history
Signed-off-by: J Robert Ray <[email protected]>
  • Loading branch information
jrray committed Dec 3, 2024
1 parent 1f8b18b commit ad67555
Show file tree
Hide file tree
Showing 42 changed files with 84 additions and 79 deletions.
2 changes: 2 additions & 0 deletions crates/spfs-cli/cmd-join/src/cmd_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ impl CmdJoin {
const ATTEMPTS_PER_SECOND: u128 = 1000u128 / TIME_TO_WAIT_BETWEEN_ATTEMPTS.as_millis();
loop {
try_counter += 1;
// Allow: this is only a unit struct on Windows.
#[allow(clippy::default_constructed_unit_structs)]
match spfs::env::RuntimeConfigurator::default().join_runtime(&spfs_runtime) {
Err(spfs::Error::String(err)) if err.contains("single-threaded") => {
// Anecdotally it takes one retry to succeed; don't start
Expand Down
6 changes: 3 additions & 3 deletions crates/spfs-vfs/src/winfsp/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ impl Handle {
/// An unowned reference to the entry data of this handle
pub fn entry(&self) -> &Entry<u64> {
match self {
Self::BlobFile { entry, .. } => &*entry,
Self::BlobStream { entry, .. } => &*entry,
Self::Tree { entry, .. } => &*entry,
Self::BlobFile { entry, .. } => entry,
Self::BlobStream { entry, .. } => entry,
Self::Tree { entry, .. } => entry,
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/spfs-vfs/src/winfsp/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl Router {
tracing::debug!("Computing environment manifest...");
let mut manifest = Err(spfs::Error::UnknownReference(env_spec.to_string()));
for repo in self.repos.iter() {
manifest = spfs::compute_environment_manifest(&env_spec, &repo).await;
manifest = spfs::compute_environment_manifest(&env_spec, repo).await;
if manifest.is_ok() {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/spfs/src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct WriteToRepositoryBlobHasher<'repo> {
}

#[tonic::async_trait]
impl<'repo> BlobHasher for WriteToRepositoryBlobHasher<'repo> {
impl BlobHasher for WriteToRepositoryBlobHasher<'_> {
async fn hash_blob(&self, reader: Pin<Box<dyn BlobRead>>) -> Result<encoding::Digest> {
self.repo.commit_blob(reader).await
}
Expand Down
6 changes: 3 additions & 3 deletions crates/spfs/src/graph/annotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<'a> AnnotationValue<'a> {
}
}

impl<'a> Display for AnnotationValue<'a> {
impl Display for AnnotationValue<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
AnnotationValue::String(v) => {
Expand All @@ -125,7 +125,7 @@ impl<'a> Display for AnnotationValue<'a> {
#[derive(Copy, Clone)]
pub struct Annotation<'buf>(pub(super) spfs_proto::Annotation<'buf>);

impl<'buf> std::fmt::Debug for Annotation<'buf> {
impl std::fmt::Debug for Annotation<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Annotation")
.field("key", &self.key())
Expand Down Expand Up @@ -193,7 +193,7 @@ impl<'buf> Annotation<'buf> {
}
}

impl<'buf> std::fmt::Display for Annotation<'buf> {
impl std::fmt::Display for Annotation<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("{}: {:?}", self.key(), self.value()))
}
Expand Down
4 changes: 2 additions & 2 deletions crates/spfs/src/graph/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<'db> DatabaseWalker<'db> {
}
}

impl<'db> Stream for DatabaseWalker<'db> {
impl Stream for DatabaseWalker<'_> {
type Item = Result<(encoding::Digest, Object)>;

fn poll_next(
Expand Down Expand Up @@ -100,7 +100,7 @@ impl<'db> DatabaseIterator<'db> {
}
}

impl<'db> Stream for DatabaseIterator<'db> {
impl Stream for DatabaseIterator<'_> {
type Item = Result<(encoding::Digest, Object)>;

fn poll_next(
Expand Down
14 changes: 7 additions & 7 deletions crates/spfs/src/graph/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod entry_test;
#[derive(Copy, Clone)]
pub struct Entry<'buf>(pub(super) spfs_proto::Entry<'buf>);

impl<'buf> std::fmt::Debug for Entry<'buf> {
impl std::fmt::Debug for Entry<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Entry")
.field("name", &self.name())
Expand Down Expand Up @@ -132,7 +132,7 @@ impl<'buf> Entry<'buf> {
}
}

impl<'buf> std::fmt::Display for Entry<'buf> {
impl std::fmt::Display for Entry<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!(
"{:06o} {:?} {} {}",
Expand All @@ -144,15 +144,15 @@ impl<'buf> std::fmt::Display for Entry<'buf> {
}
}

impl<'buf1, 'buf2> PartialEq<Entry<'buf2>> for Entry<'buf1> {
impl<'buf2> PartialEq<Entry<'buf2>> for Entry<'_> {
fn eq(&self, other: &Entry<'buf2>) -> bool {
self.0 == other.0
}
}

impl<'buf1> Eq for Entry<'buf1> {}
impl Eq for Entry<'_> {}

impl<'buf1, 'buf2> PartialOrd<Entry<'buf2>> for Entry<'buf1> {
impl<'buf2> PartialOrd<Entry<'buf2>> for Entry<'_> {
fn partial_cmp(&self, other: &Entry<'buf2>) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
Expand All @@ -169,7 +169,7 @@ impl<'buf> Ord for Entry<'buf> {
}
}

impl<'buf> encoding::Digestible for Entry<'buf> {
impl encoding::Digestible for Entry<'_> {
type Error = crate::Error;

fn digest(&self) -> std::result::Result<spfs_proto::Digest, Self::Error> {
Expand All @@ -179,7 +179,7 @@ impl<'buf> encoding::Digestible for Entry<'buf> {
}
}

impl<'buf> Entry<'buf> {
impl Entry<'_> {
pub(super) fn digest_encode(&self, writer: &mut impl std::io::Write) -> Result<()> {
encoding::write_digest(&mut *writer, self.object())?;
self.kind().encode(&mut *writer)?;
Expand Down
16 changes: 8 additions & 8 deletions crates/spfs/src/graph/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,56 +44,56 @@ pub trait HasKind {
fn kind(&self) -> ObjectKind;
}

impl<'buf> Kind for spfs_proto::Platform<'buf> {
impl Kind for spfs_proto::Platform<'_> {
#[inline]
fn kind() -> ObjectKind {
ObjectKind::Platform
}
}

impl<'buf> HasKind for spfs_proto::Platform<'buf> {
impl HasKind for spfs_proto::Platform<'_> {
#[inline]
fn kind(&self) -> ObjectKind {
<Self as Kind>::kind()
}
}

impl<'buf> Kind for spfs_proto::Layer<'buf> {
impl Kind for spfs_proto::Layer<'_> {
#[inline]
fn kind() -> ObjectKind {
ObjectKind::Layer
}
}

impl<'buf> HasKind for spfs_proto::Layer<'buf> {
impl HasKind for spfs_proto::Layer<'_> {
#[inline]
fn kind(&self) -> ObjectKind {
<Self as Kind>::kind()
}
}

impl<'buf> Kind for spfs_proto::Manifest<'buf> {
impl Kind for spfs_proto::Manifest<'_> {
#[inline]
fn kind() -> ObjectKind {
ObjectKind::Manifest
}
}

impl<'buf> HasKind for spfs_proto::Manifest<'buf> {
impl HasKind for spfs_proto::Manifest<'_> {
#[inline]
fn kind(&self) -> ObjectKind {
<Self as Kind>::kind()
}
}

impl<'buf> Kind for spfs_proto::Blob<'buf> {
impl Kind for spfs_proto::Blob<'_> {
#[inline]
fn kind() -> ObjectKind {
ObjectKind::Blob
}
}

impl<'buf> HasKind for spfs_proto::Blob<'buf> {
impl HasKind for spfs_proto::Blob<'_> {
#[inline]
fn kind(&self) -> ObjectKind {
<Self as Kind>::kind()
Expand Down
2 changes: 1 addition & 1 deletion crates/spfs/src/graph/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub struct LayerBuilder<'a> {
annotations: Vec<KeyAnnotationValuePair<'a>>,
}

impl<'a> Default for LayerBuilder<'a> {
impl Default for LayerBuilder<'_> {
fn default() -> Self {
Self {
header: super::object::HeaderBuilder::new(ObjectKind::Layer),
Expand Down
10 changes: 5 additions & 5 deletions crates/spfs/src/graph/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,11 +852,11 @@ mod private {
/// and the higher-level [`spfs_proto::AnyObject`].
pub(super) trait Sealed {}

impl<'buf> Sealed for spfs_proto::AnyObject<'buf> {}
impl<'buf> Sealed for spfs_proto::Platform<'buf> {}
impl<'buf> Sealed for spfs_proto::Layer<'buf> {}
impl<'buf> Sealed for spfs_proto::Manifest<'buf> {}
impl<'buf> Sealed for spfs_proto::Blob<'buf> {}
impl Sealed for spfs_proto::AnyObject<'_> {}
impl Sealed for spfs_proto::Platform<'_> {}
impl Sealed for spfs_proto::Layer<'_> {}
impl Sealed for spfs_proto::Manifest<'_> {}
impl Sealed for spfs_proto::Blob<'_> {}

impl<T> super::ObjectProto for T where T: Sealed {}
}
2 changes: 1 addition & 1 deletion crates/spfs/src/graph/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl serde::Serialize for Stack {

pub struct Iter<'a>(Option<&'a Entry>);

impl<'a> Iterator for Iter<'a> {
impl Iterator for Iter<'_> {
type Item = Digest;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
6 changes: 3 additions & 3 deletions crates/spfs/src/graph/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<'buf> Tree<'buf> {
}
}

impl<'buf> encoding::Digestible for Tree<'buf> {
impl encoding::Digestible for Tree<'_> {
type Error = crate::Error;

fn digest(&self) -> std::result::Result<spfs_proto::Digest, Self::Error> {
Expand All @@ -90,13 +90,13 @@ impl<'buf> encoding::Digestible for Tree<'buf> {
}
}

impl<'buf> std::fmt::Debug for Tree<'buf> {
impl std::fmt::Debug for Tree<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("Tree {{ {:?} }}", self.digest().unwrap()))
}
}

impl<'buf> HasKind for Tree<'buf> {
impl HasKind for Tree<'_> {
#[inline]
fn kind(&self) -> ObjectKind {
ObjectKind::Tree
Expand Down
4 changes: 2 additions & 2 deletions crates/spfs/src/proto/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,15 @@ impl<'a> TryFrom<Option<&'a super::annotation::Value>> for graph::AnnotationValu
}
}

impl<'buf> From<&graph::Tree<'buf>> for super::Tree {
impl From<&graph::Tree<'_>> for super::Tree {
fn from(source: &graph::Tree) -> Self {
Self {
entries: source.entries().map(|e| (&e).into()).collect(),
}
}
}

impl<'buf> From<&graph::Entry<'buf>> for super::Entry {
impl From<&graph::Entry<'_>> for super::Entry {
fn from(source: &graph::Entry) -> Self {
let kind = match source.kind() {
tracking::EntryKind::Tree => super::EntryKind::Tree as i32,
Expand Down
4 changes: 3 additions & 1 deletion crates/spfs/src/runtime/storage_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use futures::TryStreamExt;
use rstest::rstest;
use spfs_encoding::Digestible;

use super::{makedirs_with_perms, Data, Storage};
#[cfg(unix)]
use super::makedirs_with_perms;
use super::{Data, Storage};
use crate::fixtures::*;
use crate::graph::object::{DigestStrategy, EncodingFormat};
use crate::graph::{AnnotationValue, Layer, Platform};
Expand Down
2 changes: 1 addition & 1 deletion crates/spfs/src/status_win.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub async fn initialize_runtime(rt: &mut runtime::Runtime) -> Result<RenderSumma
tracing::debug!("computing runtime manifest");
let _manifest = super::compute_runtime_manifest(rt).await?;

let configurator = env::RuntimeConfigurator::default();
let configurator = env::RuntimeConfigurator;
match rt.config.mount_backend {
#[cfg(feature = "winfsp-backend")]
runtime::MountBackend::WinFsp => {
Expand Down
2 changes: 1 addition & 1 deletion crates/spfs/src/storage/fs/render_reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl<'a> MultiReporter<'a> {
}
}

impl<'a> RenderReporter for MultiReporter<'a> {
impl RenderReporter for MultiReporter<'_> {
fn visit_layer(&self, manifest: &graph::Manifest) {
for reporter in self.reporters.iter() {
reporter.visit_layer(manifest)
Expand Down
1 change: 1 addition & 0 deletions crates/spfs/src/storage/tag_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use rstest::rstest;
use tokio_stream::StreamExt;

use crate::fixtures::*;
#[cfg(unix)]
use crate::storage::fs::FsRepository;
use crate::storage::{EntryType, TagStorage};
use crate::{encoding, tracking, Result};
Expand Down
10 changes: 5 additions & 5 deletions crates/spfs/src/tracking/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ pub struct ManifestNode<'a, T = ()> {
pub entry: &'a Entry<T>,
}

impl<'a, T> ManifestNode<'a, T>
impl<T> ManifestNode<'_, T>
where
T: Clone,
{
Expand All @@ -755,15 +755,15 @@ where
}
}

impl<'a, T> PartialEq for ManifestNode<'a, T> {
impl<T> PartialEq for ManifestNode<'_, T> {
fn eq(&self, other: &Self) -> bool {
self.path == other.path && self.entry == other.entry
}
}

impl<'a, T> Eq for ManifestNode<'a, T> {}
impl<T> Eq for ManifestNode<'_, T> {}

impl<'a, T> Ord for ManifestNode<'a, T> {
impl<T> Ord for ManifestNode<'_, T> {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
use std::cmp::Ordering;

Expand Down Expand Up @@ -818,7 +818,7 @@ impl<'a, T> Ord for ManifestNode<'a, T> {
}
}

impl<'a, T> PartialOrd for ManifestNode<'a, T> {
impl<T> PartialOrd for ManifestNode<'_, T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
Expand Down
2 changes: 1 addition & 1 deletion crates/spfs/src/tracking/time_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ impl<'de> serde::de::Deserialize<'de> for TimeSpec {
{
struct TimeSpecVisitor;

impl<'de> serde::de::Visitor<'de> for TimeSpecVisitor {
impl serde::de::Visitor<'_> for TimeSpecVisitor {
type Value = TimeSpec;

fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
Expand Down
4 changes: 2 additions & 2 deletions crates/spk-build/src/validation/alter_existing_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ pub struct AlterExistingFilesValidator<'a> {
pub action: Option<&'a FileAlteration>,
}

impl<'a> super::validator::sealed::Sealed for AlterExistingFilesValidator<'a> {}
impl super::validator::sealed::Sealed for AlterExistingFilesValidator<'_> {}

#[async_trait::async_trait]
impl<'a> super::Validator for AlterExistingFilesValidator<'a> {
impl super::Validator for AlterExistingFilesValidator<'_> {
async fn validate_setup<P, V>(&self, _setup: &BuildSetupReport<P, V>) -> Report
where
P: Package,
Expand Down
4 changes: 2 additions & 2 deletions crates/spk-build/src/validation/collect_existing_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ pub struct CollectExistingFilesValidator<'a> {
pub packages: &'a Vec<NameOrCurrent>,
}

impl<'a> super::validator::sealed::Sealed for CollectExistingFilesValidator<'a> {}
impl super::validator::sealed::Sealed for CollectExistingFilesValidator<'_> {}

#[async_trait::async_trait]
impl<'a> super::Validator for CollectExistingFilesValidator<'a> {
impl super::Validator for CollectExistingFilesValidator<'_> {
async fn validate_setup<P, V>(&self, _setup: &BuildSetupReport<P, V>) -> Report
where
P: Package,
Expand Down
Loading

0 comments on commit ad67555

Please sign in to comment.