Requested feature: autoharness support for &CStr arguments under --bounded-arguments, alongside &[T] and &str.
Use case: on a whole-library verify-std run, 67 functions are skipped for a missing Arbitrary implementation on a &CStr argument, 23 of them in core (CStr::to_bytes, to_str, count_bytes, the PartialEq/Ord impls, and the rest of the CStr API).
Link to relevant documentation (Rust reference, Nomicon, RFC): https://doc.rust-lang.org/core/ffi/struct.CStr.html
A &CStr is the bytes of nondeterministic storage up to its first NUL, so it can be generated the way any_str_ref generates a &str: set the last byte of the storage to NUL and take from_bytes_until_nul, a deterministic function of the nondeterministic bytes that satisfies the invariant by construction. Slice bound, less one for the NUL.
Test case:
use std::ffi::CStr;
// Skipped: "Missing Arbitrary implementation for argument(s) s: &std::ffi::CStr".
// Expected: "Requires --bounded-arguments" without the flag; a harness once it is
// passed, and this one fails on the empty C string.
pub fn first(s: &CStr) -> u8 {
s.to_bytes()[0]
}
Requested feature: autoharness support for
&CStrarguments under--bounded-arguments, alongside&[T]and&str.Use case: on a whole-library
verify-stdrun, 67 functions are skipped for a missing Arbitrary implementation on a&CStrargument, 23 of them incore(CStr::to_bytes,to_str,count_bytes, thePartialEq/Ordimpls, and the rest of theCStrAPI).Link to relevant documentation (Rust reference, Nomicon, RFC): https://doc.rust-lang.org/core/ffi/struct.CStr.html
A
&CStris the bytes of nondeterministic storage up to its first NUL, so it can be generated the wayany_str_refgenerates a&str: set the last byte of the storage to NUL and takefrom_bytes_until_nul, a deterministic function of the nondeterministic bytes that satisfies the invariant by construction. Slice bound, less one for the NUL.Test case: