Skip to content

fix(ch05-11): use positional placeholder to keep compiler note text (#4765)#4782

Open
Dodothereal wants to merge 1 commit into
rust-lang:mainfrom
Dodothereal:fix/issue-4765-formatting-parameter-note
Open

fix(ch05-11): use positional placeholder to keep compiler note text (#4765)#4782
Dodothereal wants to merge 1 commit into
rust-lang:mainfrom
Dodothereal:fix/issue-4765-formatting-parameter-note

Conversation

@Dodothereal

Copy link
Copy Markdown

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

  • git diff: one file, one-line change (positional {}).
  • Listing still compiles; error message still mentions the trait
    not implemented.

AI assistance

Prepared with help from an AI coding assistant; reviewed end-to-end.

… 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'required by this formatting parameter' not shown after running examples from ch05-02

1 participant