From 668842197a86ffeea003a58e04e174954f2493c4 Mon Sep 17 00:00:00 2001 From: Eirik A Date: Tue, 8 Oct 2024 15:40:46 +0100 Subject: [PATCH] clippy fixes (#1596) * Clippy fixes in runtime Most from cargo +nightly clippy --fix one explicit allow because runtime has deny all. Signed-off-by: clux * clippy fixes in client and core Signed-off-by: clux --------- Signed-off-by: clux --- kube-client/src/api/core_methods.rs | 3 --- kube-core/src/duration.rs | 2 +- kube-core/src/object.rs | 1 - kube-runtime/src/controller/mod.rs | 1 + kube-runtime/src/reflector/store.rs | 4 +++- kube-runtime/src/scheduler.rs | 6 +++--- kube-runtime/src/utils/delayed_init.rs | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/kube-client/src/api/core_methods.rs b/kube-client/src/api/core_methods.rs index db149890f..323a72bce 100644 --- a/kube-client/src/api/core_methods.rs +++ b/kube-client/src/api/core_methods.rs @@ -148,7 +148,6 @@ where /// ```no_run /// # use kube::Api; /// use k8s_openapi::api::core::v1::Pod; - /// # async fn wrapper() -> Result<(), Box> { /// # let client: kube::Client = todo!(); /// let pods: Api = Api::namespaced(client, "apps"); @@ -262,10 +261,8 @@ where /// use kube::api::{Api, DeleteParams}; /// use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1 as apiexts; /// use apiexts::CustomResourceDefinition; - /// # async fn wrapper() -> Result<(), Box> { /// # let client: kube::Client = todo!(); - /// let crds: Api = Api::all(client); /// crds.delete("foos.clux.dev", &DeleteParams::default()).await? /// .map_left(|o| println!("Deleting CRD: {:?}", o.status)) diff --git a/kube-core/src/duration.rs b/kube-core/src/duration.rs index 4c2385f1b..b958a1f51 100644 --- a/kube-core/src/duration.rs +++ b/kube-core/src/duration.rs @@ -171,7 +171,7 @@ impl<'de> Deserialize<'de> for Duration { D: Deserializer<'de>, { struct Visitor; - impl<'de> de::Visitor<'de> for Visitor { + impl de::Visitor<'_> for Visitor { type Value = Duration; fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/kube-core/src/object.rs b/kube-core/src/object.rs index 2e51b3f64..1e81a947b 100644 --- a/kube-core/src/object.rs +++ b/kube-core/src/object.rs @@ -100,7 +100,6 @@ impl ObjectList { /// *elem = 2; /// println!("First element: {:?}", elem); // prints "First element: 2" /// } - pub fn iter_mut(&mut self) -> impl Iterator { self.items.iter_mut() } diff --git a/kube-runtime/src/controller/mod.rs b/kube-runtime/src/controller/mod.rs index 4a32dac36..e701b1d1b 100644 --- a/kube-runtime/src/controller/mod.rs +++ b/kube-runtime/src/controller/mod.rs @@ -332,6 +332,7 @@ const APPLIER_REQUEUE_BUF_SIZE: usize = 100; /// This is the "hard-mode" version of [`Controller`], which allows you some more customization /// (such as triggering from arbitrary [`Stream`]s), at the cost of being a bit more verbose. #[allow(clippy::needless_pass_by_value)] +#[allow(clippy::type_complexity)] pub fn applier( mut reconciler: impl FnMut(Arc, Arc) -> ReconcilerFut, error_policy: impl Fn(Arc, &ReconcilerFut::Error, Arc) -> Action, diff --git a/kube-runtime/src/reflector/store.rs b/kube-runtime/src/reflector/store.rs index f96ae6ec6..d6d264dea 100644 --- a/kube-runtime/src/reflector/store.rs +++ b/kube-runtime/src/reflector/store.rs @@ -1,4 +1,6 @@ -use super::{dispatcher::Dispatcher, Lookup, ObjectRef, ReflectHandle}; +use super::{dispatcher::Dispatcher, Lookup, ObjectRef}; +#[cfg(feature = "unstable-runtime-subscribe")] +use crate::reflector::ReflectHandle; use crate::{ utils::delayed_init::{self, DelayedInit}, watcher, diff --git a/kube-runtime/src/scheduler.rs b/kube-runtime/src/scheduler.rs index 967a5e126..1c391a136 100644 --- a/kube-runtime/src/scheduler.rs +++ b/kube-runtime/src/scheduler.rs @@ -65,7 +65,7 @@ impl Scheduler { } } -impl<'a, T: Hash + Eq + Clone, R> SchedulerProj<'a, T, R> { +impl SchedulerProj<'_, T, R> { /// Attempt to schedule a message into the queue. /// /// If the message is already in the queue then the earlier `request.run_at` takes precedence. @@ -147,7 +147,7 @@ pub struct Hold<'a, T, R> { scheduler: Pin<&'a mut Scheduler>, } -impl<'a, T, R> Stream for Hold<'a, T, R> +impl Stream for Hold<'_, T, R> where T: Eq + Hash + Clone, R: Stream>, @@ -177,7 +177,7 @@ pub struct HoldUnless<'a, T, R, C> { can_take_message: C, } -impl<'a, T, R, C> Stream for HoldUnless<'a, T, R, C> +impl Stream for HoldUnless<'_, T, R, C> where T: Eq + Hash + Clone, R: Stream>, diff --git a/kube-runtime/src/utils/delayed_init.rs b/kube-runtime/src/utils/delayed_init.rs index 7e273ae55..a80f8f8fa 100644 --- a/kube-runtime/src/utils/delayed_init.rs +++ b/kube-runtime/src/utils/delayed_init.rs @@ -61,7 +61,7 @@ impl DelayedInit { // Using a manually implemented future because we don't want to hold the lock across poll calls // since that would mean that an unpolled writer would stall all other tasks from being able to poll it struct Get<'a, T>(&'a DelayedInit); -impl<'a, T> Future for Get<'a, T> +impl Future for Get<'_, T> where T: Clone, {