-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.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
I tried this code:
fn main() {
format!(concat!("{", " f"));
}I expected to see this happen:
error: invalid format string: expected `'}'`, found `'f'`
--> src/main.rs:2:17
|
2 | format!(concat!("{", " f"));
| - ^ expected `}` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
Instead, this happened:
error: invalid format string: expected `'}'`, found `'f'`
--> src/main.rs:2:17
|
2 | format!(concat!("{", " f"));
| - ^ expected `}` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
Another more complicated example, is using include_str! (with a self-include to make playground testing easier):
fn main() {
format!(include_str!("main.rs"));
}Similar to #81070 it'd be very nice if this was able to point to the location in the included file, but if it can't it should probably have a simpler error message like "in external string included here".
Meta
Tested on stable 1.51.0 and 1.53.0-nightly (2021-04-27 727d101561f9b1e81c62)
danielhenrymantilla and lambda-fairy
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.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.