-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
#[derive(Debug)]
struct Foo(u8, u8);
fn main() {
let f = Foo(1, 2);
println!("{f:?#}");
}
Current output
error: invalid format string: expected `'}'`, found `'#'`
--> src/main.rs:6:19
|
6 | println!("{f:?#}");
| - ^ expected `'}'` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
Desired output
error: invalid format string: expected `'}'`, found `'#'`
--> src/main.rs:6:19
|
6 | println!("{f:?#}");
| ^^ help: the format parameter should be written `#?`
|
= note: if you intended to print `{`, you can escape it using `{{`
Rationale and extra context
It would be helpful to point out to the user that the format parameter should be written the other way.
Other cases
No response
Rust Version
rustc 1.83.0-nightly (d6c8169c1 2024-09-03)
binary: rustc
commit-hash: d6c8169c186ab16a3404cd0d0866674018e8a19e
commit-date: 2024-09-03
host: x86_64-pc-windows-msvc
release: 1.83.0-nightly
LLVM version: 19.1.0
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.