Skip to content

Autoharness: support &Formatter and &mut Formatter arguments under --bounded-arguments #4823

Closed

Description

@srivatsansamraj

Requested feature: autoharness support for &Formatter and &mut Formatter arguments under --bounded-arguments.

Use case: on a whole-library verify-std run, 184 functions are skipped only for a Formatter reference argument (156 in core, 21 in compiler_builtins, 5 in alloc, 2 in std): Formatter's own methods (pad, pad_integral, debug_struct, write_str and the rest), the fmt methods of Binary, Octal, LowerHex, UpperHex, LowerExp, UpperExp and Pointer, which the Debug/Display handling from #4701 does not cover, and helpers that take a Formatter, such as Duration's fmt_decimal and Ipv6Addr's fmt_subslice.

Link to relevant documentation (Rust reference, Nomicon, RFC): https://doc.rust-lang.org/nightly/core/fmt/struct.FormattingOptions.html (unstable formatting_options, rust-lang/rust#118117).

Test case:

use std::fmt::{self, Formatter};

// Skipped: "Missing Arbitrary implementation for argument(s) f: &mut std::fmt::Formatter<'_>".
// Expected: "Requires --bounded-arguments" without the flag; a harness once it is passed.
pub fn pad(f: &mut Formatter<'_>) -> fmt::Result {
    f.pad("ab")
}

Formatter::new(&mut dyn Write, FormattingOptions) and the FormattingOptions builders are public under formatting_options, and kani_core already has a sink that discards its output for the fmt-trait models. A model can build a Formatter over a harness-local sink with every option nondeterministic: width and precision unset or up to the slice bound, since they drive the padding loops; fill, alignment, sign, the alternate and zero-padding flags, and debug hex mode unrestricted. Every combination is a valid Formatter, so no value is excluded. The one limit is the sink, which never fails, so paths that handle a write error are not reached. &mut has to be admitted for this type, since fmt methods take it mutably. The kani crate would enable formatting_options.

Activity

  1. added a commit that references this issue on Sep 28, 2026
    cab1b15
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