Closed
Description
Code:
fn main() {
println!("{b} {}", a=1, b=2);
}
The current output is:
warning: named argument `a` is not used by name
--> /home/michael/test.rs:2:24
|
2 | println!("{b} {}", a=1, b=2);
| --- ^ this named argument is only referred to by position in formatting string
| |
| this formatting argument uses named argument `a` by position
|
= note: `#[warn(named_arguments_used_positionally)]` on by default
help: use the named argument by name to avoid ambiguity
|
2 | println!("{a} {}", a=1, b=2);
| ~~~
Ideally it would look like:
= note: `#[warn(named_arguments_used_positionally)]` on by default
help: use the named argument by name to avoid ambiguity
|
2 | println!("{b} {a}", a=1, b=2);
| +
- The suggestion is not exactly correct. Instead of replacing the first named arg with the suggestion, we should replace the first implicitly positional argument.
- It would also be nice if we could tighten the span on the structured suggestion (see
~~~
->+
in the before and after)