Skip to content

Conversation

@nilotpal-n7
Copy link

@nilotpal-n7 nilotpal-n7 commented Aug 16, 2025

This PR improves error messages and documentation for format strings involving alignment and formatting traits.

Highlights:

  • Clearer error messages for invalid alignment specifiers (e.g., {0:#X>18}), showing the expected <, ^, or > and a working example:

    println!("{0:>#18X}", value);

  • Updated UI test format-alignment-hash.rs to reflect the improved error output.

  • Documentation clarification: ensures examples correctly show how width, alignment, and traits like x, X, # combine.

Motivation:
Previously, using # with alignment and width produced confusing errors. This PR guides users on the correct syntax and provides actionable examples.

Testing:

  • Built the compiler (./x build)
  • Blessed and ran UI tests (./x. test src/test/ui/fmt/format-alignment-hash.rs --bless)
  • Verified full test suite passes (./x test)

Issue: #144023

@rustbot
Copy link
Collaborator

rustbot commented Aug 16, 2025

r? @SparrowLii

rustbot has assigned @SparrowLii.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 16, 2025
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

nilotpal-n7 and others added 2 commits August 17, 2025 23:10
Co-authored-by: León Orell Valerian Liehr <[email protected]>
Co-authored-by: Lieselotte <[email protected]>
@rustbot
Copy link
Collaborator

rustbot commented Aug 18, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot
Copy link
Collaborator

rustbot commented Aug 18, 2025

⚠️ Warning ⚠️

  • The following commits have merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

    You can start a rebase with the following commands:

    $ # rebase
    $ git pull --rebase https://github.com/rust-lang/rust.git master
    $ git push --force-with-lease
    

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 18, 2025
@rustbot rustbot removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 18, 2025
@nilotpal-n7 nilotpal-n7 reopened this Aug 18, 2025
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 18, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

has-merge-commits PR has merge commits, merge with caution. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants