@@ -146,12 +146,12 @@ pub struct GetSet<'a, P, T, const START: usize, const STOP: usize> {
146146
147147impl < ' a , P , T , const START : usize , const STOP : usize > GetSet < ' a , P , T , START , STOP > {
148148 /// The bit offset at which this `GetSet` instance starts
149- pub const fn start ( & self ) -> usize {
149+ # [ must_use ] pub const fn start ( & self ) -> usize {
150150 START
151151 }
152152
153153 /// The bit offset at which this `GetSet` instance ends
154- pub const fn stop ( & self ) -> usize {
154+ # [ must_use ] pub const fn stop ( & self ) -> usize {
155155 STOP
156156 }
157157}
@@ -206,7 +206,7 @@ impl<
206206 > GetSet < ' a , P , T , START , STOP >
207207{
208208 /// Get the property this `GetSet` points at
209- pub fn get ( & self ) -> T {
209+ # [ must_use ] pub fn get ( & self ) -> T {
210210 let section = self . get_raw ( ) ;
211211 // Safety:
212212 // This is guaranteed to be safe because the underlying storage must be bigger
@@ -216,14 +216,14 @@ impl<
216216
217217 /// Returns true if the memory this `GetSet` points at is a valid
218218 /// representation of `T`
219- pub fn is_valid ( & self ) -> bool {
219+ # [ must_use ] pub fn is_valid ( & self ) -> bool {
220220 let section = self . get_raw ( ) ;
221221 T :: is_valid ( section)
222222 }
223223
224224 /// Get the raw bits being pointed at, without type conversion nor any form
225225 /// of validation
226- pub fn get_raw ( & self ) -> P {
226+ # [ must_use ] pub fn get_raw ( & self ) -> P {
227227 let parent = * self . parent ;
228228 let mask = self . mask ( ) ;
229229 ( parent >> START ) & mask
@@ -373,7 +373,7 @@ macro_rules! bit_struct_impl {
373373/// A bit struct which has a zero value we can get
374374pub trait BitStructZero : Zero {
375375 /// Get a zero value for this bit struct
376- fn bs_zero ( ) -> Self {
376+ # [ must_use ] fn bs_zero ( ) -> Self {
377377 Self :: zero ( )
378378 }
379379}
@@ -540,6 +540,8 @@ macro_rules! bit_struct {
540540 impl $crate:: BitStruct <{ $( <$actual as $crate:: ValidCheck <$kind>>:: ALWAYS_VALID &&) * true } > for $name {
541541 type Kind = $kind;
542542
543+ /// # Safety
544+ /// - This is implemented automatically by the bit-struct crate.
543545 unsafe fn from_unchecked( inner: $kind) -> Self {
544546 Self ( unsafe { $crate:: UnsafeStorage :: new_unsafe( inner) } )
545547 }
@@ -548,12 +550,16 @@ macro_rules! bit_struct {
548550 #[ allow( clippy:: used_underscore_binding) ]
549551 impl $name {
550552
553+ /// # Safety
554+ /// - This is implemented automatically by the bit-struct crate.
551555 unsafe fn from_unchecked( inner: $kind) -> Self {
552556 Self ( unsafe { $crate:: UnsafeStorage :: new_unsafe( inner) } )
553557 }
554558
555559 #[ allow( clippy:: too_many_arguments) ]
556560 pub fn new( $( $field: $actual) ,* ) -> Self {
561+ // SAFETY:
562+ // - This is implemented automatically by the bit-struct crate.
557563 let mut res = unsafe { Self :: from_unchecked( <$kind as $crate:: BitStructZero >:: bs_zero( ) ) } ;
558564 $(
559565 res. $field( ) . set( $field) ;
@@ -607,7 +613,7 @@ macro_rules! count_idents {
607613/// assert_eq!(bits(5), 3);
608614/// assert_eq!(bits(32), 6);
609615/// ```
610- pub const fn bits ( num : usize ) -> usize {
616+ # [ must_use ] pub const fn bits ( num : usize ) -> usize {
611617 /// Helper function for [`bits`]
612618 const fn helper ( count : usize , on : usize ) -> usize {
613619 // 0b11 = 3 log2_ceil(0b11) = 2 .. 2^2
@@ -637,6 +643,7 @@ macro_rules! enum_impl {
637643 } ;
638644 ( VALID_CORE $name: ident: [ $( $kind: ty) ,* ] ) => {
639645 $(
646+ #[ allow( clippy:: undocumented_unsafe_blocks, clippy:: use_self) ]
640647 unsafe impl $crate:: ValidCheck <$kind> for $name {
641648 const ALWAYS_VALID : bool = <Self as $crate:: ValidCheck <u8 >>:: ALWAYS_VALID ;
642649 fn is_valid( value: $kind) -> bool {
@@ -653,6 +660,7 @@ macro_rules! enum_impl {
653660 } ;
654661 ( VALID_BIT_STRUCT $name: ident: [ $( $kind: ty) ,* ] ) => {
655662 $(
663+ #[ allow( clippy:: undocumented_unsafe_blocks, clippy:: use_self) ]
656664 unsafe impl $crate:: ValidCheck <$kind> for $name {
657665 const ALWAYS_VALID : bool = <Self as $crate:: ValidCheck <u8 >>:: ALWAYS_VALID ;
658666 fn is_valid( value: $kind) -> bool {
@@ -709,14 +717,19 @@ macro_rules! enum_impl {
709717 ) ,*
710718 }
711719
720+ /// # Safety
721+ /// - This is implemented automatically by the bit-struct crate.
722+ #[ allow( clippy:: use_self) ]
712723 unsafe impl $crate:: BitCount for $name {
713724 const COUNT : usize = $crate:: bits( $crate:: count_idents!( 0 , [ $( $field) ,* ] ) ) ;
714725 }
715726
727+ #[ allow( clippy:: use_self) ]
716728 impl $name {
717729 const VARIANT_COUNT : usize = $crate:: enum_impl!( COUNT $fst_field $( , $field) * ) ;
718730 }
719731
732+ #[ allow( clippy:: undocumented_unsafe_blocks, clippy:: use_self) ]
720733 unsafe impl $crate:: ValidCheck <u8 > for $name {
721734 const ALWAYS_VALID : bool = Self :: VARIANT_COUNT . count_ones( ) == 1 ;
722735 fn is_valid( value: u8 ) -> bool {
@@ -730,6 +743,7 @@ macro_rules! enum_impl {
730743
731744 $crate:: enum_impl!( FROM_IMPLS $name) ;
732745
746+ #[ allow( clippy:: use_self) ]
733747 impl Default for $name {
734748 fn default ( ) -> Self {
735749 Self :: $default
@@ -762,6 +776,7 @@ macro_rules! enum_impl {
762776 ) ,*
763777 }
764778
779+ #[ allow( clippy:: use_self) ]
765780 impl Default for $name {
766781 fn default ( ) -> Self {
767782 Self :: $fst_field
@@ -772,11 +787,12 @@ macro_rules! enum_impl {
772787 const VARIANT_COUNT : usize = $crate:: enum_impl!( COUNT $fst_field $( , $field) * ) ;
773788 }
774789
790+ #[ allow( clippy:: undocumented_unsafe_blocks) ]
775791 unsafe impl $crate:: BitCount for $name {
776792 const COUNT : usize = $crate:: bits( $crate:: count_idents!( 0 , [ $( $field) ,* ] ) ) ;
777793 }
778794
779-
795+ # [ allow ( clippy :: undocumented_unsafe_blocks ) ]
780796 unsafe impl $crate:: ValidCheck <u8 > for $name {
781797 const ALWAYS_VALID : bool = Self :: VARIANT_COUNT . count_ones( ) == 1 ;
782798
0 commit comments