diff --git a/src/lib.rs b/src/lib.rs index 852422c..6ff98f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -359,13 +359,36 @@ impl_arbitrary_for_integers! { u32; u64; u128; - usize; i8; i16; i32; i64; i128; - isize; +} + +// Note: We forward Arbitrary for i/usize to i/u64 in order to simplify corpus +// compatibility between 32-bit and 64-bit builds. This introduces dead space in +// 32-bit builds but keeps the input layout independent of the build platform. +impl<'a> Arbitrary<'a> for usize { + fn arbitrary(u: &mut Unstructured<'a>) -> Result { + u.arbitrary::().map(|x| x as usize) + } + + #[inline] + fn size_hint(depth: usize) -> (usize, Option) { + ::size_hint(depth) + } +} + +impl<'a> Arbitrary<'a> for isize { + fn arbitrary(u: &mut Unstructured<'a>) -> Result { + u.arbitrary::().map(|x| x as isize) + } + + #[inline] + fn size_hint(depth: usize) -> (usize, Option) { + ::size_hint(depth) + } } macro_rules! impl_arbitrary_for_floats {