diff --git a/src/lib.rs b/src/lib.rs index 7303ffde8a..3ac89fe66b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -172,6 +172,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, @@ -1026,6 +1027,7 @@ pub unsafe trait FromZeroes { /// * Panics if `size_of::() * len` overflows. /// * Panics if allocation of `size_of::() * len` bytes fails. #[cfg(feature = "alloc")] + #[allow(clippy::expect_used)] #[inline] fn new_box_slice_zeroed(len: usize) -> Box<[Self]> where @@ -1415,10 +1417,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(()) } } @@ -2241,6 +2240,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::())