Fix format string grammar in docs and improve alignment error message #144023 #145512
+36
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
./x build
)./x. test src/test/ui/fmt/format-alignment-hash.rs --bless
)./x test
)Issue: #144023