diff --git a/examples/configmapgen_controller.rs b/examples/configmapgen_controller.rs index 499ef5e09..6fa3efc06 100644 --- a/examples/configmapgen_controller.rs +++ b/examples/configmapgen_controller.rs @@ -1,3 +1,6 @@ +// Nightly clippy (0.1.64) considers Drop a side effect, see https://github.com/rust-lang/rust-clippy/issues/9608 +#![allow(clippy::unnecessary_lazy_evaluations)] + use anyhow::Result; use futures::StreamExt; use k8s_openapi::api::core::v1::ConfigMap; @@ -50,14 +53,14 @@ async fn reconcile(generator: Arc, ctx: Arc) -> Result .metadata .namespace .as_ref() - .ok_or(Error::MissingObjectKey(".metadata.namespace"))?, + .ok_or_else(|| Error::MissingObjectKey(".metadata.namespace"))?, ); cm_api .patch( cm.metadata .name .as_ref() - .ok_or(Error::MissingObjectKey(".metadata.name"))?, + .ok_or_else(|| Error::MissingObjectKey(".metadata.name"))?, &PatchParams::apply("configmapgenerator.kube-rt.nullable.se"), &Patch::Apply(&cm), ) diff --git a/kube-client/src/api/portforward.rs b/kube-client/src/api/portforward.rs index 4a009b7be..95cdec531 100644 --- a/kube-client/src/api/portforward.rs +++ b/kube-client/src/api/portforward.rs @@ -278,7 +278,7 @@ where match msg { Message::FromPod(ch, mut bytes) => { let ch = ch as usize; - let channel = chan_state.get_mut(ch).ok_or(Error::InvalidChannel(ch))?; + let channel = chan_state.get_mut(ch).ok_or_else(|| Error::InvalidChannel(ch))?; let port_index = ch / 2; // Initialization @@ -327,7 +327,7 @@ where } Message::ToPodClose(ch) => { let ch = ch as usize; - let channel = chan_state.get_mut(ch).ok_or(Error::InvalidChannel(ch))?; + let channel = chan_state.get_mut(ch).ok_or_else(|| Error::InvalidChannel(ch))?; let port_index = ch / 2; if !channel.shutdown { diff --git a/kube-client/src/config/file_config.rs b/kube-client/src/config/file_config.rs index 0975950ac..bdfec434b 100644 --- a/kube-client/src/config/file_config.rs +++ b/kube-client/src/config/file_config.rs @@ -480,7 +480,7 @@ fn load_from_base64_or_file>( let data = value .map(load_from_base64) .or_else(|| file.as_ref().map(load_from_file)) - .unwrap_or(Err(LoadDataError::NoBase64DataOrFile))?; + .unwrap_or_else(|| Err(LoadDataError::NoBase64DataOrFile))?; Ok(ensure_trailing_newline(data)) } diff --git a/kube-client/src/lib.rs b/kube-client/src/lib.rs index ff80e36bb..9fcccccd0 100644 --- a/kube-client/src/lib.rs +++ b/kube-client/src/lib.rs @@ -63,6 +63,8 @@ #![cfg_attr(docsrs, feature(doc_cfg))] #![deny(missing_docs)] #![forbid(unsafe_code)] +// Nightly clippy (0.1.64) considers Drop a side effect, see https://github.com/rust-lang/rust-clippy/issues/9608 +#![allow(clippy::unnecessary_lazy_evaluations)] macro_rules! cfg_client { ($($item:item)*) => { diff --git a/kube-core/src/schema.rs b/kube-core/src/schema.rs index 1b1675506..308ee3573 100644 --- a/kube-core/src/schema.rs +++ b/kube-core/src/schema.rs @@ -72,7 +72,7 @@ fn hoist_subschema_properties( common_obj: &mut Option>, instance_type: &mut Option>, ) { - let common_obj = common_obj.get_or_insert_with(|| Box::new(ObjectValidation::default())); + let common_obj = common_obj.get_or_insert_with(Box::::default); for variant in subschemas { if let Schema::Object(SchemaObject { @@ -90,7 +90,7 @@ fn hoist_subschema_properties( { let metadata = variant_object .metadata - .get_or_insert_with(|| Box::new(Metadata::default())); + .get_or_insert_with(Box::::default); metadata.description = Some(description); } } diff --git a/kube-runtime/src/controller/mod.rs b/kube-runtime/src/controller/mod.rs index c6c4850d9..b3cd9ed08 100644 --- a/kube-runtime/src/controller/mod.rs +++ b/kube-runtime/src/controller/mod.rs @@ -194,7 +194,7 @@ impl Display for ReconcileReason { ReconcileReason::Unknown => f.write_str("unknown"), ReconcileReason::ObjectUpdated => f.write_str("object updated"), ReconcileReason::RelatedObjectUpdated { obj_ref: object } => { - f.write_fmt(format_args!("related object updated: {}", object)) + f.write_fmt(format_args!("related object updated: {object}")) } ReconcileReason::BulkReconcile => f.write_str("bulk reconcile requested"), ReconcileReason::ReconcilerRequestedRetry => f.write_str("reconciler requested retry"), diff --git a/kube-runtime/src/finalizer.rs b/kube-runtime/src/finalizer.rs index 372688143..4800e3a84 100644 --- a/kube-runtime/src/finalizer.rs +++ b/kube-runtime/src/finalizer.rs @@ -129,7 +129,7 @@ where // Short-circuit, so that we keep the finalizer if cleanup fails .map_err(Error::CleanupFailed)?; // Cleanup was successful, remove the finalizer so that deletion can continue - let finalizer_path = format!("/metadata/finalizers/{}", finalizer_i); + let finalizer_path = format!("/metadata/finalizers/{finalizer_i}"); api.patch::( &name, &PatchParams::default(), diff --git a/kube-runtime/src/reflector/object_ref.rs b/kube-runtime/src/reflector/object_ref.rs index 3aa7dedf7..cc2049ca1 100644 --- a/kube-runtime/src/reflector/object_ref.rs +++ b/kube-runtime/src/reflector/object_ref.rs @@ -201,7 +201,7 @@ impl Display for ObjectRef { self.name )?; if let Some(namespace) = &self.namespace { - write!(f, ".{}", namespace)?; + write!(f, ".{namespace}")?; } Ok(()) } @@ -251,11 +251,11 @@ mod tests { #[test] fn display_should_be_transparent_to_representation() { let pod_ref = ObjectRef::::new("my-pod").within("my-namespace"); - assert_eq!(format!("{}", pod_ref), format!("{}", pod_ref.erase())); + assert_eq!(format!("{pod_ref}"), format!("{}", pod_ref.erase())); let deploy_ref = ObjectRef::::new("my-deploy").within("my-namespace"); - assert_eq!(format!("{}", deploy_ref), format!("{}", deploy_ref.erase())); + assert_eq!(format!("{deploy_ref}"), format!("{}", deploy_ref.erase())); let node_ref = ObjectRef::::new("my-node"); - assert_eq!(format!("{}", node_ref), format!("{}", node_ref.erase())); + assert_eq!(format!("{node_ref}"), format!("{}", node_ref.erase())); } #[test] diff --git a/kube-runtime/src/watcher.rs b/kube-runtime/src/watcher.rs index 14bf5d767..be2ac092c 100644 --- a/kube-runtime/src/watcher.rs +++ b/kube-runtime/src/watcher.rs @@ -284,7 +284,7 @@ pub fn watch_object impl Stream>> + Send { watcher(api, ListParams { - field_selector: Some(format!("metadata.name={}", name)), + field_selector: Some(format!("metadata.name={name}")), ..Default::default() }) .map(|event| match event? {