Skip to content

Commit

Permalink
fix compilation errors, remove cfg warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacholt100 committed Sep 18, 2024
1 parent 6b5dd7f commit 9bb4d9f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 16 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ lto = true # enable link-time optimisation for faster runtime, but slower compil
opt-level = 3 # maximum optimisation level for faster runtime, but slower compile time

[package.metadata.docs.rs]
all-features = true
all-features = true

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(test_int_bits, values("64", "128"))'] }
3 changes: 3 additions & 0 deletions changes/v0.12.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Add optional borsh support
- Add `digits_mut` method to unsigned integers.
- `As` and `CastFrom` traits no longer const, as const trait support removed from latest nightly.
6 changes: 3 additions & 3 deletions src/buint/as_float.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::ExpType;
use crate::cast::CastFrom;

#[cfg_attr(feature = "nightly", const_trait)]
// #[cfg_attr(feature = "nightly", const_trait)]
pub trait CastToFloatHelper: Copy {
const ZERO: Self;
const BITS: ExpType;
Expand Down Expand Up @@ -93,7 +93,7 @@ pub(crate) use impl_helper_buint;

crate::macro_impl!(impl_helper_buint);

#[cfg_attr(feature = "nightly", const_trait)]
// #[cfg_attr(feature = "nightly", const_trait)]
pub trait CastToFloatConsts {
type M: Mantissa;

Expand Down Expand Up @@ -131,7 +131,7 @@ macro_rules! cast_to_float_consts {

cast_to_float_consts!(f32; u32, f64; u64);

#[cfg_attr(feature = "nightly", const_trait)]
// #[cfg_attr(feature = "nightly", const_trait)]
pub trait Mantissa {
const ONE: Self;
const TWO: Self;
Expand Down
18 changes: 11 additions & 7 deletions src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
/// Backend implementation trait for panic-free casting between numeric types.
#[cfg_attr(feature = "nightly", const_trait)]
// #[cfg_attr(feature = "nightly", const_trait)]
pub trait CastFrom<T> {
fn cast_from(from: T) -> Self;
}

#[cfg_attr(feature = "nightly", const_trait)]
// #[cfg_attr(feature = "nightly", const_trait)]
pub(crate) trait CastTo<U> {
fn cast_to(self) -> U;
}
Expand Down Expand Up @@ -54,17 +54,19 @@ assert_eq!(b, f.as_());
#[cfg(feature = "nightly")]
macro_rules! as_trait {
() => {
impl<T, U> const CastTo<U> for T
// impl<T, U> const CastTo<U> for T
impl<T, U> CastTo<U> for T
where
U: ~const CastFrom<T>,
// U: ~const CastFrom<T>,
U: CastFrom<T>,
{
fn cast_to(self) -> U {
U::cast_from(self)
}
}

#[doc = as_trait_doc!()]
#[const_trait]
// #[const_trait]
pub trait As {
#[doc = as_method_doc!()]
fn as_<T>(self) -> T
Expand All @@ -73,11 +75,13 @@ macro_rules! as_trait {
Self: Sized;
}

impl<U> const As for U {
// impl<U> const As for U {
impl<U> As for U {
#[inline]
fn as_<T>(self) -> T
where
T: ~const CastFrom<Self>,
// T: ~const CastFrom<Self>,
T: CastFrom<Self>,
Self: Sized,
{
T::cast_from(self)
Expand Down
3 changes: 0 additions & 3 deletions src/int/numtraits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,19 +299,16 @@ macro_rules! prim_int_methods {
fn pow(self, exp: u32) -> Self;
}

#[cfg(has_leading_trailing_ones)]
#[inline]
fn leading_ones(self) -> u32 {
Self::leading_ones(self)
}

#[cfg(has_leading_trailing_ones)]
#[inline]
fn trailing_ones(self) -> u32 {
Self::trailing_ones(self)
}

#[cfg(has_reverse_bits)]
#[inline]
fn reverse_bits(self) -> Self {
Self::reverse_bits(self)
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
generic_const_exprs,
const_trait_impl,
const_option_ext,
effects,
// effects,
)
)]
#![cfg_attr(
Expand Down
2 changes: 1 addition & 1 deletion src/nightly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub(crate) use impl_const;
#[cfg(feature = "nightly")]
macro_rules! const_impl {
{ impl $(<$(const $C: ident : $ty: ty), +>)? const $($tt: tt) + } => {
impl $(<$(const $C: $ty), +>)? const $($tt) +
impl $(<$(const $C: $ty), +>)? $($tt) +
}
}

Expand Down

0 comments on commit 9bb4d9f

Please sign in to comment.