Detect Python-style f-string debug syntax in format strings and emit a
clear diagnostic explaining that it is not supported in Rust. When the
intended operation can be inferred, suggest the corresponding Rust
alternative e.g from `println!("{=}", x)` to `dbg!({x})`.
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
17 lines
496 B
Text
17 lines
496 B
Text
error: invalid format string: python's f-string debug `=` is not supported in rust, use `dbg(x)` instead
|
|
--> $DIR/format-string-error-3.rs:4:16
|
|
|
|
|
LL | println!("{=}", x);
|
|
| -^ expected `}` in format string
|
|
| |
|
|
| because of this opening brace
|
|
|
|
|
= note: to print `{`, you can escape it using `{{`
|
|
help: use rust debug printing macro
|
|
|
|
|
LL - println!("{=}", x);
|
|
LL + dbg!(x);
|
|
|
|
|
|
|
error: aborting due to 1 previous error
|
|
|