On fmt string with unescaped {
note how to escape
On cases of malformed format strings where a `{` hasn't been properly escaped, like `println!("{");`, present a note explaining how to escape the `{` char.
This commit is contained in:
parent
da2ce22768
commit
3c17abc4d9
4 changed files with 61 additions and 6 deletions
20
src/test/ui/fmt/format-string-error.stderr
Normal file
20
src/test/ui/fmt/format-string-error.stderr
Normal file
|
@ -0,0 +1,20 @@
|
|||
error: invalid format string: expected `'}'` but string was terminated
|
||||
--> $DIR/format-string-error.rs:12:5
|
||||
|
|
||||
12 | println!("{");
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: if you intended to print `{`, you can escape it using `{{`
|
||||
= note: this error originates in a macro outside of the current crate
|
||||
|
||||
error: invalid format string: unmatched `}` found
|
||||
--> $DIR/format-string-error.rs:14:5
|
||||
|
|
||||
14 | println!("}");
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: if you intended to print `}`, you can escape it using `}}`
|
||||
= note: this error originates in a macro outside of the current crate
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue