-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Suggest examples of format specifiers in error messages #68293
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
This is real code that someone I am helping learn Rust wrote today. It's a problem you could easily stare at for hours and never figure it out. Especially if you're new to using format strings. The code actually looks correct (from a distance).
Here's the error message we produce:
The person I was helping assumed that some formatting trait hadn't been implemented. It didn't occur to them that the format specifier was incorrect even though it said "formatting specifier missing".
I think we could help them by adding a hint or something that shows an example of a specifier whenever we say "formatting specifier missing".
Something like:
This would then help them compare against what they have and find the problem sooner.
From @estebank: (source)