From 2d07496423354a1f8a7bbfaeba2827e39acd40da Mon Sep 17 00:00:00 2001 From: Andrew Gazelka Date: Tue, 28 May 2024 12:31:06 -0500 Subject: [PATCH] fix clippy lints (#137) --- bytemuck/src/checked.rs | 5 +---- bytemuck_derive/src/traits.rs | 7 ++++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bytemuck/src/checked.rs b/bytemuck/src/checked.rs index 493269c..0634e12 100644 --- a/bytemuck/src/checked.rs +++ b/bytemuck/src/checked.rs @@ -165,10 +165,7 @@ unsafe impl CheckedBitPattern for bool { #[inline] fn is_valid_bit_pattern(bits: &Self::Bits) -> bool { - match *bits { - 0 | 1 => true, - _ => false, - } + matches!(*bits, 0 | 1) } } diff --git a/bytemuck_derive/src/traits.rs b/bytemuck_derive/src/traits.rs index 24ae8f5..7924f59 100644 --- a/bytemuck_derive/src/traits.rs +++ b/bytemuck_derive/src/traits.rs @@ -441,7 +441,11 @@ impl Derivable for Contiguous { quote!(), quote! { type Int = #integer_ty; + + #[allow(clippy::missing_docs_in_private_items)] const MIN_VALUE: #integer_ty = #min_lit; + + #[allow(clippy::missing_docs_in_private_items)] const MAX_VALUE: #integer_ty = #max_lit; #[inline] @@ -526,6 +530,7 @@ fn generate_checked_bit_pattern_struct( #repr #[derive(Clone, Copy, #crate_name::AnyBitPattern)] #derive_dbg + #[allow(missing_docs)] pub struct #bits_ty { #(#field_name: <#field_ty as #crate_name::CheckedBitPattern>::Bits,)* } @@ -534,7 +539,7 @@ fn generate_checked_bit_pattern_struct( type Bits = #bits_ty; #[inline] - #[allow(clippy::double_comparisons)] + #[allow(clippy::double_comparisons, unused)] fn is_valid_bit_pattern(bits: &#bits_ty) -> bool { #(<#field_ty as #crate_name::CheckedBitPattern>::is_valid_bit_pattern(&{ bits.#field_name }) && )* true }