Skip to content

Commit

Permalink
refactor(utils): use the int_bits_const feature
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
yvt committed Oct 1, 2020
1 parent 01b9443 commit 03ba166
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/constance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#![feature(unsafe_block_in_unsafe_fn)] // `unsafe fn` doesn't imply `unsafe {}`
#![feature(never_type)] // `!`
#![feature(specialization)]
#![feature(int_bits_const)]
#![feature(untagged_unions)] // `union` with non-`Copy` fields
#![cfg_attr(test, feature(is_sorted))]
#![deny(unsafe_op_in_unsafe_fn)]
Expand Down
1 change: 0 additions & 1 deletion src/constance/src/utils/ctz.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Count trailing zeros
#![allow(clippy::if_same_then_else)]
use super::int::BinInteger;

const USIZE_BITS: u32 = usize::BITS;

Expand Down
2 changes: 1 addition & 1 deletion src/constance/src/utils/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ macro_rules! impl_binary_integer {
impl BinInteger for $type {
type OneDigits = OneDigits<Self>;

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

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

0 comments on commit 03ba166

Please sign in to comment.