Skip to content

Commit

Permalink
clippy fixes (#1596)
Browse files Browse the repository at this point in the history
* Clippy fixes in runtime

Most from cargo +nightly clippy --fix
one explicit allow because runtime has deny all.

Signed-off-by: clux <[email protected]>

* clippy fixes in client and core

Signed-off-by: clux <[email protected]>

---------

Signed-off-by: clux <[email protected]>
  • Loading branch information
clux authored Oct 8, 2024
1 parent 3c3939f commit 6688421
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 10 deletions.
3 changes: 0 additions & 3 deletions kube-client/src/api/core_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ where
/// ```no_run
/// # use kube::Api;
/// use k8s_openapi::api::core::v1::Pod;

/// # async fn wrapper() -> Result<(), Box<dyn std::error::Error>> {
/// # let client: kube::Client = todo!();
/// let pods: Api<Pod> = Api::namespaced(client, "apps");
Expand Down Expand Up @@ -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<dyn std::error::Error>> {
/// # let client: kube::Client = todo!();

/// let crds: Api<CustomResourceDefinition> = Api::all(client);
/// crds.delete("foos.clux.dev", &DeleteParams::default()).await?
/// .map_left(|o| println!("Deleting CRD: {:?}", o.status))
Expand Down
2 changes: 1 addition & 1 deletion kube-core/src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion kube-core/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ impl<T: Clone> ObjectList<T> {
/// *elem = 2;
/// println!("First element: {:?}", elem); // prints "First element: 2"
/// }

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
self.items.iter_mut()
}
Expand Down
1 change: 1 addition & 0 deletions kube-runtime/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<K, QueueStream, ReconcilerFut, Ctx>(
mut reconciler: impl FnMut(Arc<K>, Arc<Ctx>) -> ReconcilerFut,
error_policy: impl Fn(Arc<K>, &ReconcilerFut::Error, Arc<Ctx>) -> Action,
Expand Down
4 changes: 3 additions & 1 deletion kube-runtime/src/reflector/store.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
6 changes: 3 additions & 3 deletions kube-runtime/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<T, R: Stream> Scheduler<T, R> {
}
}

impl<'a, T: Hash + Eq + Clone, R> SchedulerProj<'a, T, R> {
impl<T: Hash + Eq + Clone, R> 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.
Expand Down Expand Up @@ -147,7 +147,7 @@ pub struct Hold<'a, T, R> {
scheduler: Pin<&'a mut Scheduler<T, R>>,
}

impl<'a, T, R> Stream for Hold<'a, T, R>
impl<T, R> Stream for Hold<'_, T, R>
where
T: Eq + Hash + Clone,
R: Stream<Item = ScheduleRequest<T>>,
Expand Down Expand Up @@ -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<T, R, C> Stream for HoldUnless<'_, T, R, C>
where
T: Eq + Hash + Clone,
R: Stream<Item = ScheduleRequest<T>>,
Expand Down
2 changes: 1 addition & 1 deletion kube-runtime/src/utils/delayed_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<T: Clone + Send + Sync> DelayedInit<T> {
// 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<T>);
impl<'a, T> Future for Get<'a, T>
impl<T> Future for Get<'_, T>
where
T: Clone,
{
Expand Down

0 comments on commit 6688421

Please sign in to comment.