diff --git a/library/core/src/num/saturating.rs b/library/core/src/num/saturating.rs index 3f4791e163e69..6426d6460fea2 100644 --- a/library/core/src/num/saturating.rs +++ b/library/core/src/num/saturating.rs @@ -1,6 +1,8 @@ //! Definitions of `Saturating`. use crate::fmt; +#[cfg(kani)] +use crate::kani; use crate::ops::{ Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign, @@ -37,6 +39,14 @@ use crate::ops::{ #[rustc_diagnostic_item = "Saturating"] pub struct Saturating(#[stable(feature = "saturating_int_impl", since = "1.74.0")] pub T); +#[cfg(kani)] +#[stable(feature = "saturating_int_impl", since = "1.74.0")] +impl kani::Arbitrary for Saturating { + fn any() -> Self { + Self { 0: kani::any() } + } +} + #[stable(feature = "saturating_int_impl", since = "1.74.0")] impl fmt::Debug for Saturating { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/library/core/src/num/wrapping.rs b/library/core/src/num/wrapping.rs index 55fa91d0b9f49..491845f6ef8f4 100644 --- a/library/core/src/num/wrapping.rs +++ b/library/core/src/num/wrapping.rs @@ -1,6 +1,8 @@ //! Definitions of `Wrapping`. use crate::fmt; +#[cfg(kani)] +use crate::kani; use crate::ops::{ Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign, @@ -42,6 +44,14 @@ use crate::ops::{ #[rustc_diagnostic_item = "Wrapping"] pub struct Wrapping(#[stable(feature = "rust1", since = "1.0.0")] pub T); +#[cfg(kani)] +#[stable(feature = "rust1", since = "1.0.0")] +impl kani::Arbitrary for Wrapping { + fn any() -> Self { + Self { 0: kani::any() } + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Wrapping { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/library/portable-simd/crates/core_simd/src/vector.rs b/library/portable-simd/crates/core_simd/src/vector.rs index d76a6cd52bfc5..4bbc4f59732bb 100644 --- a/library/portable-simd/crates/core_simd/src/vector.rs +++ b/library/portable-simd/crates/core_simd/src/vector.rs @@ -5,6 +5,9 @@ use crate::simd::{ ptr::{SimdConstPtr, SimdMutPtr}, }; +#[cfg(kani)] +use crate::kani; + /// A SIMD vector with the shape of `[T; N]` but the operations of `T`. /// /// `Simd` supports the operators (+, *, etc.) that `T` does in "elementwise" fashion. @@ -100,6 +103,7 @@ use crate::simd::{ // avoided, as it will likely become illegal on `#[repr(simd)]` structs in the future. It also // causes rustc to emit illegal LLVM IR in some cases. #[repr(simd, packed)] +#[cfg_attr(kani, derive(kani::Arbitrary))] pub struct Simd([T; N]) where LaneCount: SupportedLaneCount,