Skip to content

Autoharness: support &Wtf8 arguments under --bounded-arguments #4808

Description

@srivatsansamraj

Requested feature: autoharness support for &Wtf8 arguments under --bounded-arguments, beside &str, &CStr (#4803) and &ByteStr (#4805).

Use case: on a whole-library verify-std run, 32 functions in core are skipped for a missing Arbitrary implementation on a &Wtf8 argument: the wtf8::Wtf8 methods (len, as_str, code_points, encode_wide, next_surrogate and the rest) and its trait implementations (PartialEq, Ord, Hash, Debug, Display, the range Indexes).

Link to relevant documentation (Rust reference, Nomicon, RFC): https://simonsapin.github.io/wtf-8/ (the encoding). The type is core::wtf8::Wtf8, #[doc(hidden)] and gated on wtf8_internals, the representation behind OsStr on Windows.

Test case:

#![feature(wtf8_internals)]
#![allow(internal_features)]
use core::wtf8::Wtf8;

// Skipped: "Missing Arbitrary implementation for argument(s) s: &core::wtf8::Wtf8".
// Expected: "Requires --bounded-arguments" without the flag; a harness once it is
// passed, and this one fails on the empty string.
pub fn first(s: &Wtf8) -> u8 {
    s.as_bytes()[0]
}

WTF-8 is a superset of UTF-8, so the existing bounded string model gives a sound value: Wtf8::from_str over any_str_ref, with the string bound. That leaves out strings holding surrogate code points, the case WTF-8 exists for; generating those needs a WTF-8 validator that core does not expose. Whether an internal, doc(hidden) type is worth a model is the question here; the kani crate would enable wtf8_internals to name it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions