You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
u16 format precision change, breach of the Rust stability guarantee #140250
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:
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:
Breaches the Rust stability guarantee
Is causing real regressions (5 reports, and it's been out in beta only, so far)
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.
Reacted by David Tolnay, Josh Triplett, Taiki Endo, Ben Kimock, Josh Stone, Mateusz Mikuła and 许杰友 Jieyou Xu (Joe)
Reacted by scottmcm, Mateusz Mikuła and 许杰友 Jieyou Xu (Joe)
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.
Activity
jieyouxu commentedon Apr 24, 2025
You can nominate this for library team (re-)discussion.
@rustbot label: I-libs-nominated
jieyouxu commentedon Apr 24, 2025
Also FYI @m-ou-se
m-ou-se commentedon Apr 24, 2025
Nominated this for @rust-lang/libs-api
m-ou-se commentedon Apr 24, 2025
My (probably slightly biased) analysis:
Of those five cases listed above, three are only example strings in unit tests. In
fourall 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:
Other cases:
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 commentedon Apr 29, 2025
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.