Skip to content

Commit 03ba166

Browse files
committed
refactor(utils): use the int_bits_const feature
`int_bits_const` feature [1] adds `i32::BITS`, etc. We already have `BitInteger` trait, which has `BitInteger::BITS`, and using it triggers `unstable_name_collision` compatibility lint [2] unless `int_bits_const` is explicitly enabled, gets stabilized or gets rejected and removed from the compiler. [1]: rust-lang/rust#76492 [2]: rust-lang/rust#48919
1 parent 01b9443 commit 03ba166

File tree

3 files changed

+2
-2
lines changed

3 files changed

+2
-2
lines changed

src/constance/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#![feature(unsafe_block_in_unsafe_fn)] // `unsafe fn` doesn't imply `unsafe {}`
1414
#![feature(never_type)] // `!`
1515
#![feature(specialization)]
16+
#![feature(int_bits_const)]
1617
#![feature(untagged_unions)] // `union` with non-`Copy` fields
1718
#![cfg_attr(test, feature(is_sorted))]
1819
#![deny(unsafe_op_in_unsafe_fn)]

src/constance/src/utils/ctz.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Count trailing zeros
22
#![allow(clippy::if_same_then_else)]
3-
use super::int::BinInteger;
43

54
const USIZE_BITS: u32 = usize::BITS;
65

src/constance/src/utils/int.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ macro_rules! impl_binary_integer {
9696
impl BinInteger for $type {
9797
type OneDigits = OneDigits<Self>;
9898

99-
const BITS: u32 = core::mem::size_of::<$type>() as u32 * 8;
99+
const BITS: u32 = <$type>::BITS;
100100

101101
#[inline]
102102
fn ones(range: ops::Range<u32>) -> Self {

0 commit comments

Comments
 (0)