Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Be safe #637

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/std_extensions/arithmetic/int_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/std_extensions/quantum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down