From f3ccd4b827781f7915fad8db51954b3295096d62 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Wed, 16 Aug 2023 01:59:13 -0700 Subject: [PATCH] Make some Clippy lints more strict Once #61 is done, we'll forbid the `missing_safety_docs` and `undocumented_unsafe_blocks` Clippy lints to the root module. Until that happens, we forbid them as high in the module tree as possible. --- src/byteorder.rs | 2 ++ src/derive_util.rs | 1 + src/lib.rs | 4 ++++ zerocopy-derive/src/lib.rs | 3 ++- zerocopy-derive/src/repr.rs | 4 +--- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/byteorder.rs b/src/byteorder.rs index 82d7cd30d32..b898096d587 100644 --- a/src/byteorder.rs +++ b/src/byteorder.rs @@ -61,6 +61,8 @@ //! } //! ``` +#![forbid(clippy::missing_safety_doc, clippy::undocumented_unsafe_blocks)] + use core::{ convert::{TryFrom, TryInto}, fmt::{self, Binary, Debug, Display, Formatter, LowerHex, Octal, UpperHex}, diff --git a/src/derive_util.rs b/src/derive_util.rs index 8f72ef09c6d..abda473eff0 100644 --- a/src/derive_util.rs +++ b/src/derive_util.rs @@ -12,6 +12,7 @@ //! different times). #![allow(missing_debug_implementations)] +#![forbid(clippy::missing_safety_doc, clippy::undocumented_unsafe_blocks)] use core::marker::PhantomData; diff --git a/src/lib.rs b/src/lib.rs index a0246ccc70a..17ef49bdab5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1111,6 +1111,8 @@ safety_comment! { // [2] https://github.com/rust-lang/unsafe-code-guidelines/issues/38 #[cfg(feature = "simd")] mod simd { + #![forbid(clippy::missing_safety_doc, clippy::undocumented_unsafe_blocks)] + /// Defines a module which implements `FromZeroes`, `FromBytes`, and /// `AsBytes` for a set of types from a module in `core::arch`. /// @@ -2786,6 +2788,8 @@ unsafe impl<'a> ByteSliceMut for RefMut<'a, [u8]> {} #[cfg(feature = "alloc")] mod alloc_support { + #![forbid(clippy::missing_safety_doc, clippy::undocumented_unsafe_blocks)] + use alloc::vec::Vec; use super::*; diff --git a/zerocopy-derive/src/lib.rs b/zerocopy-derive/src/lib.rs index 8e1b9801998..43aaca6baba 100644 --- a/zerocopy-derive/src/lib.rs +++ b/zerocopy-derive/src/lib.rs @@ -12,7 +12,8 @@ // our MSRV. #![allow(unknown_lints)] #![deny(renamed_and_removed_lints)] -#![deny(clippy::all, clippy::missing_safety_doc)] +#![deny(clippy::all)] +#![forbid(clippy::missing_safety_doc, clippy::undocumented_unsafe_blocks)] #![deny( rustdoc::bare_urls, rustdoc::broken_intra_doc_links, diff --git a/zerocopy-derive/src/repr.rs b/zerocopy-derive/src/repr.rs index 5bd4a8a9115..5997ad2f2ff 100644 --- a/zerocopy-derive/src/repr.rs +++ b/zerocopy-derive/src/repr.rs @@ -73,9 +73,7 @@ impl Config { } let initial_sp = metas[0].span(); - let err_span = metas.iter().skip(1).fold(Some(initial_sp), |sp_option, meta| { - sp_option.and_then(|sp| sp.join(meta.span())) - }); + let err_span = metas.iter().skip(1).try_fold(initial_sp, |sp, meta| sp.join(meta.span())); if self.allowed_combinations.contains(&reprs.as_slice()) { Ok(reprs)