Closed
Description
The suggestion that rustc gives is incorrect and seems to not take into account what characters are in the format argument.
I tried this code:
println!("hello {:?}", world = "world");
I expected to see this happen:
|
2 | println!("hello {:?}", world = "world");
| ---- ^^^^^ this named argument is referred to by position in formatting string
| |
| this formatting argument uses named argument `world` by position
|
= note: `#[warn(named_arguments_used_positionally)]` on by default
help: use the named argument by name to avoid ambiguity
|
2 | println!("hello {world:?}", world = "world");
| ~~~~~
Instead, this happened:
|
2 | println!("hello {:?}", world = "world");
| ---- ^^^^^ this named argument is referred to by position in formatting string
| |
| this formatting argument uses named argument `world` by position
|
= note: `#[warn(named_arguments_used_positionally)]` on by default
help: use the named argument by name to avoid ambiguity
|
2 | println!("hello {world}", world = "world");
| ~~~~~
Meta
Using beta.2/nightly
rustc --version --verbose
:
rustc 1.65.0-nightly (40336865f 2022-08-15)
binary: rustc
commit-hash: 40336865fe7d4a01139a3336639c6971647e885c
commit-date: 2022-08-15
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0