Skip to content

Implement kani::Arbitrary for Wrapping, Saturating, and Simd types #328

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

carolynzech
Copy link

@carolynzech carolynzech commented Apr 17, 2025

Implement kani::Arbitrary for the Wrapping, Saturating, and Simd types.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@carolynzech carolynzech requested a review from a team as a code owner April 17, 2025 20:34
Copy link
Member

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes as proposed below (with an additional

#[cfg(kani)]
use crate::kani;

at the top of the files) appear to work for me.

@tautschnig
Copy link
Member

With the changes as proposed above plus an additional

--- a/library/portable-simd/crates/core_simd/src/vector.rs
+++ b/library/portable-simd/crates/core_simd/src/vector.rs
@@ -1,3 +1,5 @@
+#[cfg(kani)]
+use crate::kani;
 use crate::simd::{
     LaneCount, Mask, MaskElement, SupportedLaneCount, Swizzle,
     cmp::SimdPartialOrd,
@@ -99,6 +101,7 @@ use crate::simd::{
 // directly constructing an instance of the type (i.e. `let vector = Simd(array)`) should be
 // 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.
+#[cfg_attr(kani, derive(kani::Arbitrary))]
 #[repr(simd, packed)]
 pub struct Simd<T, const N: usize>([T; N])
 where

we get 1039 further harnesses.

The implementations need a stability attribute.

Co-authored-by: Michael Tautschnig <[email protected]>
@carolynzech carolynzech requested a review from tautschnig April 18, 2025 15:31
@carolynzech carolynzech changed the title Derive kani::Arbitrary for Wrapping and Saturating types Implement kani::Arbitrary for Wrapping, Saturating, and Simd types Apr 18, 2025
@carolynzech carolynzech force-pushed the wrapping-saturating-derive branch from c460d6d to d508266 Compare April 18, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants