Skip to content

Tracking issue for release notes of #136932: Reduce formatting width and precision to 16 bits #137014

Open
@rustbot

Description

@rustbot

This issue tracks the release notes text for #136932.

Steps

  • Proposed text is drafted by PR author (or team) making the noteworthy change.
  • Issue is nominated for release team review of clarity for wider audience.
  • Release team includes text in release notes/blog posts.

Release notes text

The responsible team for the underlying change should edit this section to replace the automatically generated link with a succinct description of what changed, drawing upon text proposed by the author (either in discussion or through direct editing).

# Compatibility notes
- [Limit `width` and `precision` formatting options to 16 bits on all targets](https://github.com/rust-lang/rust/pull/136932)

Tip

Use the previous releases categories to help choose which one(s) to use.
The category will be de-duplicated with all the other ones by the release team.

More than one section can be included if needed.

Release blog section

If the change is notable enough for inclusion in the blog post, the responsible team should add content to this section.
Otherwise leave it empty.

#### Reduced limit on the width and precision formatting options

The width and precision options in a format string such as `println!("{a:1234}")` are now both limited to 65535 (`u16::MAX`). Previously, these were both limited to the `usize::MAX` of rustc, and led to runtime bugs if cross-compiled from a host with larger `usize` to a target with smaller `usize`; the new limit is the minimum size of `usize` on any target.

Specifying a width or precision higher than 65535 will now result in a compiler error.

The new limit also applies to dynamic width or precision, such as in `println!("{a:.*$}", 100000)`. Providing a dynamic width or precision higher than 65535 will result in a runtime panic.

cc @m-ou-se, @m-ou-se -- origin issue/PR authors and assignees for starting to draft text

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-fmtArea: `core::fmt`T-libsRelevant to the library team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.relnotesMarks issues that should be documented in the release notes of the next release.relnotes-tracking-issueMarks issues tracking what text to put in release notes.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions