From cc340d8b4d96ecd44509fd6e3f90741062c5aacc Mon Sep 17 00:00:00 2001 From: Magnus Ulimoen Date: Tue, 19 Sep 2023 21:09:04 +0200 Subject: [PATCH] Clippy lint fixes --- hdf5-sys/src/h5p.rs | 4 ++-- hdf5/src/class.rs | 2 +- hdf5/src/hl/chunks.rs | 2 +- hdf5/src/hl/container.rs | 4 ++-- hdf5/src/hl/dataset.rs | 6 +++--- hdf5/src/hl/plist/dataset_access.rs | 3 ++- hdf5/src/hl/plist/dataset_create.rs | 3 ++- hdf5/src/hl/plist/file_access.rs | 5 +++-- hdf5/src/hl/plist/file_create.rs | 3 ++- hdf5/src/hl/plist/link_create.rs | 3 ++- hdf5/src/hl/selection.rs | 2 +- 11 files changed, 21 insertions(+), 16 deletions(-) diff --git a/hdf5-sys/src/h5p.rs b/hdf5-sys/src/h5p.rs index 572a8b643..11ef9ac40 100644 --- a/hdf5-sys/src/h5p.rs +++ b/hdf5-sys/src/h5p.rs @@ -130,7 +130,7 @@ mod globals { #[cfg(feature = "1.12.0")] #[allow(clippy::module_inception)] - pub mod globals { + pub mod globals_inner { use super::*; extern_static!(H5P_MAP_CREATE, H5P_CLS_MAP_CREATE_ID_g); extern_static!(H5P_MAP_ACCESS, H5P_CLS_MAP_ACCESS_ID_g); @@ -142,7 +142,7 @@ mod globals { extern_static!(H5P_REFERENCE_ACCESS_DEFAULT, H5P_LST_REFERENCE_ACCESS_ID_g); } #[cfg(feature = "1.12.0")] - pub use globals::*; + pub use globals_inner::*; } #[cfg(all(not(feature = "1.8.14"), all(target_env = "msvc", not(feature = "static"))))] diff --git a/hdf5/src/class.rs b/hdf5/src/class.rs index e859b14f9..66a2c5314 100644 --- a/hdf5/src/class.rs +++ b/hdf5/src/class.rs @@ -27,7 +27,7 @@ pub trait ObjectClass: Sized { let handle = Handle::try_new(id)?; if Self::is_valid_id_type(handle.id_type()) { let obj = Self::from_handle(handle); - obj.validate().map(|_| obj) + obj.validate().map(|()| obj) } else { Err(From::from(format!("Invalid {} id: {}", Self::NAME, id))) } diff --git a/hdf5/src/hl/chunks.rs b/hdf5/src/hl/chunks.rs index d07021622..a84ac68ae 100644 --- a/hdf5/src/hl/chunks.rs +++ b/hdf5/src/hl/chunks.rs @@ -72,7 +72,7 @@ mod v1_14_0 { use super::*; use hdf5_sys::h5d::H5Dchunk_iter; - /// Borrowed version of [ChunkInfo](crate::dataset::ChunkInfo) + /// Borrowed version of [`ChunkInfo`](crate::dataset::ChunkInfo) #[derive(Clone, Debug, PartialEq, Eq)] pub struct ChunkInfoRef<'a> { pub offset: &'a [hsize_t], diff --git a/hdf5/src/hl/container.rs b/hdf5/src/hl/container.rs index 1c371edec..ca59b40f8 100644 --- a/hdf5/src/hl/container.rs +++ b/hdf5/src/hl/container.rs @@ -130,7 +130,7 @@ impl<'a> Reader<'a> { pub fn read_raw(&self) -> Result> { let size = self.obj.space()?.size(); let mut vec = Vec::with_capacity(size); - self.read_into_buf(vec.as_mut_ptr(), None, None).map(|_| { + self.read_into_buf(vec.as_mut_ptr(), None, None).map(|()| { unsafe { vec.set_len(size); }; @@ -184,7 +184,7 @@ impl<'a> Reader<'a> { let obj_ndim = self.obj.get_shape()?.ndim(); ensure!(obj_ndim == 0, "ndim mismatch: expected scalar, got {}", obj_ndim); let mut val = mem::MaybeUninit::::uninit(); - self.read_into_buf(val.as_mut_ptr(), None, None).map(|_| unsafe { val.assume_init() }) + self.read_into_buf(val.as_mut_ptr(), None, None).map(|()| unsafe { val.assume_init() }) } } diff --git a/hdf5/src/hl/dataset.rs b/hdf5/src/hl/dataset.rs index 26415fde3..641c54bef 100644 --- a/hdf5/src/hl/dataset.rs +++ b/hdf5/src/hl/dataset.rs @@ -396,7 +396,7 @@ impl DatasetBuilderInner { Some(dapl) => dapl.clone(), None => DatasetAccess::try_new()?, }; - self.dapl_builder.apply(&mut dapl).map(|_| dapl) + self.dapl_builder.apply(&mut dapl).map(|()| dapl) } fn compute_chunk_shape(&self, dtype: &Datatype, extents: &Extents) -> Result>> { @@ -468,7 +468,7 @@ impl DatasetBuilderInner { Some(dcpl) => dcpl.clone(), None => DatasetCreate::try_new()?, }; - dcpl_builder.apply(&mut dcpl).map(|_| dcpl) + dcpl_builder.apply(&mut dcpl).map(|()| dcpl) } fn build_lcpl(&self) -> Result { @@ -476,7 +476,7 @@ impl DatasetBuilderInner { Some(lcpl) => lcpl.clone(), None => LinkCreate::try_new()?, }; - self.lcpl_builder.apply(&mut lcpl).map(|_| lcpl) + self.lcpl_builder.apply(&mut lcpl).map(|()| lcpl) } fn try_unlink<'n, N: Into>>(&self, name: N) { diff --git a/hdf5/src/hl/plist/dataset_access.rs b/hdf5/src/hl/plist/dataset_access.rs index 996013473..a3f4a6932 100644 --- a/hdf5/src/hl/plist/dataset_access.rs +++ b/hdf5/src/hl/plist/dataset_access.rs @@ -223,6 +223,7 @@ impl DatasetAccessBuilder { Ok(()) } + #[allow(clippy::needless_pass_by_ref_mut)] pub fn apply(&self, plist: &mut DatasetAccess) -> Result<()> { h5lock!(self.populate_plist(plist.id())) } @@ -230,7 +231,7 @@ impl DatasetAccessBuilder { pub fn finish(&self) -> Result { h5lock!({ let mut plist = DatasetAccess::try_new()?; - self.apply(&mut plist).map(|_| plist) + self.apply(&mut plist).map(|()| plist) }) } } diff --git a/hdf5/src/hl/plist/dataset_create.rs b/hdf5/src/hl/plist/dataset_create.rs index c9f96ebac..0579a4e3d 100644 --- a/hdf5/src/hl/plist/dataset_create.rs +++ b/hdf5/src/hl/plist/dataset_create.rs @@ -650,6 +650,7 @@ impl DatasetCreateBuilder { !self.filters.is_empty() } + #[allow(clippy::needless_pass_by_ref_mut)] pub fn apply(&self, plist: &mut DatasetCreate) -> Result<()> { h5lock!(self.populate_plist(plist.id())) } @@ -657,7 +658,7 @@ impl DatasetCreateBuilder { pub fn finish(&self) -> Result { h5lock!({ let mut plist = DatasetCreate::try_new()?; - self.apply(&mut plist).map(|_| plist) + self.apply(&mut plist).map(|()| plist) }) } } diff --git a/hdf5/src/hl/plist/file_access.rs b/hdf5/src/hl/plist/file_access.rs index 6d0e050bc..8f9148163 100644 --- a/hdf5/src/hl/plist/file_access.rs +++ b/hdf5/src/hl/plist/file_access.rs @@ -1482,6 +1482,7 @@ impl FileAccessBuilder { Ok(()) } + #[allow(clippy::needless_pass_by_ref_mut)] pub fn apply(&self, plist: &mut FileAccess) -> Result<()> { h5lock!(self.populate_plist(plist.id())) } @@ -1489,7 +1490,7 @@ impl FileAccessBuilder { pub fn finish(&self) -> Result { h5lock!({ let mut plist = FileAccess::try_new()?; - self.apply(&mut plist).map(|_| plist) + self.apply(&mut plist).map(|()| plist) }) } } @@ -1575,7 +1576,7 @@ impl FileAccess { } let relax = relax > 0; let drv = MultiDriver { files, layout, relax }; - drv.validate().map(|_| drv) + drv.validate().map(|()| drv) } #[doc(hidden)] diff --git a/hdf5/src/hl/plist/file_create.rs b/hdf5/src/hl/plist/file_create.rs index 03b105da1..07a24cfa3 100644 --- a/hdf5/src/hl/plist/file_create.rs +++ b/hdf5/src/hl/plist/file_create.rs @@ -424,6 +424,7 @@ impl FileCreateBuilder { Ok(()) } + #[allow(clippy::needless_pass_by_ref_mut)] pub fn apply(&self, plist: &mut FileCreate) -> Result<()> { h5lock!(self.populate_plist(plist.id())) } @@ -431,7 +432,7 @@ impl FileCreateBuilder { pub fn finish(&self) -> Result { h5lock!({ let mut plist = FileCreate::try_new()?; - self.apply(&mut plist).map(|_| plist) + self.apply(&mut plist).map(|()| plist) }) } } diff --git a/hdf5/src/hl/plist/link_create.rs b/hdf5/src/hl/plist/link_create.rs index b18196806..1439d02fd 100644 --- a/hdf5/src/hl/plist/link_create.rs +++ b/hdf5/src/hl/plist/link_create.rs @@ -120,6 +120,7 @@ impl LinkCreateBuilder { Ok(()) } + #[allow(clippy::needless_pass_by_ref_mut)] pub fn apply(&self, plist: &mut LinkCreate) -> Result<()> { h5lock!(self.populate_plist(plist.id())) } @@ -127,7 +128,7 @@ impl LinkCreateBuilder { pub fn finish(&self) -> Result { h5lock!({ let mut plist = LinkCreate::try_new()?; - self.apply(&mut plist).map(|_| plist) + self.apply(&mut plist).map(|()| plist) }) } } diff --git a/hdf5/src/hl/selection.rs b/hdf5/src/hl/selection.rs index ce0893296..f91e774ac 100644 --- a/hdf5/src/hl/selection.rs +++ b/hdf5/src/hl/selection.rs @@ -103,7 +103,7 @@ fn check_coords(coords: &Array2, shape: &[Ix]) -> Result<()> { let ndim = coords.shape()[1]; ensure!(ndim == shape.len(), "Slice ndim ({}) != shape ndim ({})", ndim, shape.len()); for (i, &dim) in shape.iter().enumerate() { - for &d in coords.slice(s![.., i]).iter() { + for &d in coords.slice(s![.., i]) { ensure!(d < dim, "Index {} out of bounds for axis {} with size {}", d, i, dim); } }