diff --git a/src/lib.rs b/src/lib.rs index e03495448e..34902bc84e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -181,6 +181,7 @@ clippy::correctness, clippy::dbg_macro, clippy::decimal_literal_representation, + clippy::expect_used, clippy::get_unwrap, clippy::indexing_slicing, clippy::missing_inline_in_public_items, @@ -219,6 +220,7 @@ // production code introduce the possibly of code panicking unexpectedly "in // the field". clippy::arithmetic_side_effects, + clippy::expect_used, clippy::indexing_slicing, ))] #![cfg_attr(not(test), no_std)] @@ -1072,6 +1074,7 @@ pub unsafe trait FromZeroes { /// * Panics if allocation of `size_of::() * len` bytes fails. #[cfg(feature = "alloc")] #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] + #[allow(clippy::expect_used)] #[inline] fn new_box_slice_zeroed(len: usize) -> Box<[Self]> where @@ -1681,10 +1684,7 @@ pub unsafe trait AsBytes { #[inline] fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()> { let start = bytes.len().checked_sub(mem::size_of_val(self))?; - bytes - .get_mut(start..) - .expect("`start` should be in-bounds of `bytes`") - .copy_from_slice(self.as_bytes()); + bytes.get_mut(start..)?.copy_from_slice(self.as_bytes()); Some(()) } } @@ -2652,6 +2652,7 @@ where /// `new_slice` panics if `T` is a zero-sized type. #[inline] pub fn new_slice(bytes: B) -> Option> { + #[allow(clippy::expect_used)] let remainder = bytes .len() .checked_rem(mem::size_of::())