fix(ch05-11): use positional placeholder to keep compiler note text (#4765)#4782
Open
Dodothereal wants to merge 1 commit into
Open
fix(ch05-11): use positional placeholder to keep compiler note text (#4765)#4782Dodothereal wants to merge 1 commit into
Dodothereal wants to merge 1 commit into
Conversation
… formatting parameter' note Fixes rust-lang#4765: with recent rustc (>=1.86 / inline capture-of-format-args defaults), the error emitted for 'println!("rect1 is {rect1}")' no longer prints the 'required by this formatting parameter' annotation. Modern rustc omits the note for inline captured identifiers. Switching the listing to 'println!("rect1 is {}", rect1)' makes the error output match the text reproduced in the chapter (which still mentions the note), so the book's narrative stays in sync.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #4765
Summary
With recent rustc releases (where the inline-format-args capture is
the default), the compiler no longer emits the 'required by this
formatting parameter' note for 'println!("rect1 is {rect1}")'.
The chapter still quotes that note verbatim in the chapter text, so
the listing's example no longer matches what the book says. Switched
the listing to use a positional placeholder ('... {}', rect1) which
restores the note in the compiler output and preserves the narrative.
Test plan
not implemented.
AI assistance
Prepared with help from an AI coding assistant; reviewed end-to-end.