Skip to content

Commit

Permalink
Change the error message for multiple unused print params
Browse files Browse the repository at this point in the history
  • Loading branch information
perryprog committed Jul 19, 2017
1 parent 83c659e commit 0fcb4fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
8 changes: 6 additions & 2 deletions src/libsyntax_ext/format.rs
Expand Up @@ -798,9 +798,13 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt,
} else {
let mut diag = cx.ecx.struct_span_err(cx.fmtsp,
"multiple unused formatting arguments");
for (sp, msg) in errs {
diag.span_note(sp, msg);

// Ignoring message, as it gets repetitive
// Then use MultiSpan to not clutter up errors
for (sp, _) in errs {
diag.span_label(sp, "unused");
}

diag
}
};
Expand Down
21 changes: 5 additions & 16 deletions src/test/ui/macros/format-foreign.stderr
Expand Up @@ -2,23 +2,12 @@ error: multiple unused formatting arguments
--> $DIR/format-foreign.rs:12:5
|
12 | println!("%.*3$s %s!/n", "Hello,", "World", 4);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^--------^^-------^^-^^
| | | |
| | | unused
| | unused
| unused
|
note: argument never used
--> $DIR/format-foreign.rs:12:30
|
12 | println!("%.*3$s %s!/n", "Hello,", "World", 4);
| ^^^^^^^^
note: argument never used
--> $DIR/format-foreign.rs:12:40
|
12 | println!("%.*3$s %s!/n", "Hello,", "World", 4);
| ^^^^^^^
note: argument never used
--> $DIR/format-foreign.rs:12:49
|
12 | println!("%.*3$s %s!/n", "Hello,", "World", 4);
| ^
= help: `%.*3$s` should be written as `{:.2$}`
= help: `%s` should be written as `{}`
= note: printf formatting not supported; see the documentation for `std::fmt`
Expand Down

0 comments on commit 0fcb4fc

Please sign in to comment.