Skip to content

u16 format precision change, breach of the Rust stability guarantee #140250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ijackson opened this issue Apr 24, 2025 · 5 comments
Closed

u16 format precision change, breach of the Rust stability guarantee #140250

ijackson opened this issue Apr 24, 2025 · 5 comments
Labels
A-fmt Area: `core::fmt` A-stability Area: `#[stable]`, `#[unstable]` etc. C-bug Category: This is a bug. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@ijackson
Copy link
Contributor

Hi. I have been following #136932, where format! is changed to panic on widths and precisions of more than 16 bits. (This is for performance reasons, as it makes FormattingOptions much smaller.)

When this was originally proposed, a crater run was performed. This showed two regressions:

Since then, we have also had more regressions reported:

This seems to show that this change is not merely a theoretical problem, but causes real regressions. The statement that it "affects almost no existing code" turns out to have been overly optimistic.

I appreciate the efforts to improve things, but it seems to me that this change:

I think the decison to merge #136932 should be reconsidered in the light of this new information.

What is the process for that?

@ijackson ijackson added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Apr 24, 2025
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 24, 2025
@jieyouxu jieyouxu added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Apr 24, 2025
@jieyouxu
Copy link
Member

You can nominate this for library team (re-)discussion.
@rustbot label: I-libs-nominated

@rustbot rustbot added the I-libs-nominated Nominated for discussion during a libs team meeting. label Apr 24, 2025
@jieyouxu jieyouxu added A-stability Area: `#[stable]`, `#[unstable]` etc. A-fmt Area: `core::fmt` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 24, 2025
@jieyouxu
Copy link
Member

Also FYI @m-ou-se

@m-ou-se m-ou-se added I-libs-api-nominated Nominated for discussion during a libs-api team meeting. and removed I-libs-nominated Nominated for discussion during a libs team meeting. labels Apr 24, 2025
@m-ou-se
Copy link
Member

m-ou-se commented Apr 24, 2025

Nominated this for @rust-lang/libs-api

@m-ou-se
Copy link
Member

m-ou-se commented Apr 24, 2025

My (probably slightly biased) analysis:

Of those five cases listed above, three are only example strings in unit tests. In four all five cases, the author confirmed that they thought this change to Rust was acceptable.

Cases where this only broke an example string in a unit test:

  • uutils/coreutils: The author agreed the change to rust is reasonable and was happy to change their test right away. I asked for their input before we made the change.
  • kitware ghostflow: The author wrote: "It is test code, so not too much to shed tears over."
  • object-store: Found in the most recent crater run. Author agreed we shouldn't roll the change back.

Other cases:

  • vasekp/stream-rust: This actually uncovered a subtle bug and the author was happy to update their code. I asked for their input before we merged the change.
  • strftime-ruby: This was found right after merging. I checked with the maintainers that the change was acceptable, and they actually thanked us for working on improving the performance of formatting in Rust.

All the broken tests had subtly non-portable code: on a 16-bit platform, the widths would be silently truncated resulting in wrong outputs and failed tests. The breaking change is fixing that bug, by only guaranteeing 16 bits which we know exists on all targets.

This all seems well within the range of acceptable to me. Especially because we changed a potential silent subtle bug (even if only on small platforms) to a clear error.

@joshtriplett
Copy link
Member

We discussed this in today's @rust-lang/libs-api meeting. We agreed with @m-ou-se's report on the issue, namely that all the affected crates were fine with this change. Based on this, we're planning to continue with this change.

@joshtriplett joshtriplett closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2025
@jieyouxu jieyouxu removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 29, 2025
@apiraino apiraino removed I-libs-api-nominated Nominated for discussion during a libs-api team meeting. regression-untriaged Untriaged performance or correctness regression. labels Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-fmt Area: `core::fmt` A-stability Area: `#[stable]`, `#[unstable]` etc. C-bug Category: This is a bug. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants