Skip to content

Commit

Permalink
Make some Clippy lints more strict
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joshlf committed Aug 16, 2023
1 parent 2a406e8 commit f3ccd4b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/byteorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
1 change: 1 addition & 0 deletions src/derive_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//! different times).
#![allow(missing_debug_implementations)]
#![forbid(clippy::missing_safety_doc, clippy::undocumented_unsafe_blocks)]

use core::marker::PhantomData;

Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
///
Expand Down Expand Up @@ -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::*;
Expand Down
3 changes: 2 additions & 1 deletion zerocopy-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions zerocopy-derive/src/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ impl<R: KindRepr> Config<R> {
}

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)
Expand Down

0 comments on commit f3ccd4b

Please sign in to comment.