Skip to content

fix(rust): Display string pin credits a changed format placeholder #9836

Closed

Description

@EffortlessSteven

Found by a read-only review of #9682 (comment 6351427568). changes_only_string_literals in classify/related_tests/fmt_dispatch.rs strips string-literal contents and compares the rest, so any edit inside the format string counts as a literal-text change, including the {..} placeholders themselves.

Repro

write!(f, "{}°C", self.0) pinned by assert_eq!(Temp(21).to_string(), "21°C"):

  • "{}°C" to "{:?}°C" prints 21°C for an integer; the pin still passes.
  • "{}" to "{0}", "{:}" or "{:<1}" (width no wider than the value) print the same for the chosen value.
  • {{ / }} escape edits can cancel on a value that has no braces.

The tail is credited exposed where a mutant survives. Narrow, but it is the false-credit direction we fail closed on.

Goal it hurts

Trustworthy verdicts: no false exposed. The idiom-display-string-pin row is unaffected, so no existing corpus row catches this.

Fix

Treat a changed string as literal-only only when the edit leaves the ordered list of {..} placeholder groups identical after unescaping {{ / }}. Negatives: "{}°C" to "{:?}°C", to "{0}°C", and a {{ escape edit stay weakly_exposed; positive: only the °C text changes.

Owner: this thread. Follows #9682.

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