Open
Description
format!
currently doesn't support inline expressions, like format!("{binding.field}");
, but the error it emits while serviceable isn't great:
error: invalid format string: expected `'}'`, found `'.'`
--> src/main.rs:10:23
|
10 | println!("{binding.field}");
| - ^ expected `}` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
It would be much better experience if we started parsing first field access expressions, potentially method calls and later arbitrary expressions and explicitly told the user "you can't do that, move the expression to its own binding". If we were to ever attempt to support this, prototyping the machinery for diagnostics first would also be informative about its limits or potential problems.
error: invalid format string: field access isn't supported
--> src/main.rs:10:23
|
10 | println!("{binding.field}");
| ^^^^^^^^^^^^^ not supported
help: consider using a positional formatting argument instead
|
10 | println!("{}", binding.field);
| -- +++++++++++++