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); } }