Tweak duplicate fmt arg error

This commit is contained in:
Esteban Küber 2019-11-25 12:34:16 -08:00
parent 9c97d73a2d
commit 1eeed17c9e
2 changed files with 5 additions and 8 deletions

View File

@ -172,7 +172,8 @@ fn parse_args<'a>(
let e = p.parse_expr()?;
if let Some(prev) = names.get(&name) {
ecx.struct_span_err(e.span, &format!("duplicate argument named `{}`", name))
.span_note(args[*prev].span, "previously here")
.span_label(args[*prev].span, "previously here")
.span_label(e.span, "duplicate argument")
.emit();
continue;
}

View File

@ -138,13 +138,9 @@ error: duplicate argument named `foo`
--> $DIR/ifmt-bad-arg.rs:40:33
|
LL | format!("{foo}", foo=1, foo=2);
| ^
|
note: previously here
--> $DIR/ifmt-bad-arg.rs:40:26
|
LL | format!("{foo}", foo=1, foo=2);
| ^
| - ^ duplicate argument
| |
| previously here
error: positional arguments cannot follow named arguments
--> $DIR/ifmt-bad-arg.rs:41:35