Skip to content

suggest {var:?} when finding {:?var} in inline format strings #106572

Closed
@matthiaskrgr

Description

@matthiaskrgr
    eprintln!("Timings:\n{:?timer}");

The current suggestion is:

error: invalid format string: expected `'}'`, found `'t'`
   --> src/main.rs:696:29
    |
696 |     eprintln!("Timings:\n{:?timer}");
    |                          -  ^ expected `}` in format string
    |                          |
    |                          because of this opening brace
    |
    = note: if you intended to print `{`, you can escape it using `{{`

error: could not compile `icemaker` due to previous error

We could perhaps detect the formatting parameter is at the beginning of the fmt string and that it should go at the end, in order to suggest {timer:?}

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions