From 5a3cbdf383a6620ba3a3c6bb9ae9ff075de6c4d3 Mon Sep 17 00:00:00 2001 From: Alec Edgington Date: Wed, 1 Nov 2023 13:46:31 +0000 Subject: [PATCH 1/2] Remove unsafety. --- src/std_extensions/arithmetic/int_types.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/std_extensions/arithmetic/int_types.rs b/src/std_extensions/arithmetic/int_types.rs index 7989b6c8c..536be3774 100644 --- a/src/std_extensions/arithmetic/int_types.rs +++ b/src/std_extensions/arithmetic/int_types.rs @@ -48,11 +48,10 @@ const fn is_valid_log_width(n: u8) -> bool { pub const LOG_WIDTH_BOUND: u8 = 7; /// Type parameter for the log width of the integer. -// SAFETY: unsafe block should be ok as the value is definitely not zero. #[allow(clippy::assertions_on_constants)] -pub const LOG_WIDTH_TYPE_PARAM: TypeParam = TypeParam::bounded_nat(unsafe { +pub const LOG_WIDTH_TYPE_PARAM: TypeParam = TypeParam::bounded_nat({ assert!(LOG_WIDTH_BOUND > 0); - NonZeroU64::new_unchecked(LOG_WIDTH_BOUND as u64) + NonZeroU64::MIN.saturating_add(LOG_WIDTH_BOUND as u64 - 1) }); /// Get the log width of the specified type argument or error if the argument From d09856335d3483b9d8c9a0e5e0ba99fc50bffd42 Mon Sep 17 00:00:00 2001 From: Alec Edgington Date: Wed, 1 Nov 2023 13:47:21 +0000 Subject: [PATCH 2/2] Remove unneeded clippy annotation. --- src/std_extensions/quantum.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/std_extensions/quantum.rs b/src/std_extensions/quantum.rs index 0768db280..2c8d67498 100644 --- a/src/std_extensions/quantum.rs +++ b/src/std_extensions/quantum.rs @@ -44,7 +44,6 @@ const fn is_valid_log_denom(n: u8) -> bool { } /// Type parameter for the log-denominator of an angle. -#[allow(clippy::assertions_on_constants)] pub const LOG_DENOM_TYPE_PARAM: TypeParam = TypeParam::bounded_nat(NonZeroU64::MIN.saturating_add(LOG_DENOM_MAX as u64));