Skip to content

Commit f0b07ca

Browse files
committed
Auto merge of #43323 - perryprog:master, r=estebank
Less verbose output for unused arguments Closes #37718 This is my first contribution to rust, so sorry if I'm missing anything! The output now looks like this: <img width="831" alt="screen shot 2017-07-18 at 5 01 32 pm" src="https://user-images.githubusercontent.com/12972285/28347566-dbfa9962-6c05-11e7-8730-c2e8062a04cc.png"> It's not the prettiest, but whenever #41850 gets resolved, this should be able to be improved. **EDIT:** This also does not seem r? @Mark-Simulacrum
2 parents 68be86d + 5c10db3 commit f0b07ca

File tree

4 files changed

+91
-18
lines changed

4 files changed

+91
-18
lines changed

src/libsyntax_ext/format.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -798,9 +798,13 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt,
798798
} else {
799799
let mut diag = cx.ecx.struct_span_err(cx.fmtsp,
800800
"multiple unused formatting arguments");
801-
for (sp, msg) in errs {
802-
diag.span_note(sp, msg);
801+
802+
// Ignoring message, as it gets repetitive
803+
// Then use MultiSpan to not clutter up errors
804+
for (sp, _) in errs {
805+
diag.span_label(sp, "unused");
803806
}
807+
804808
diag
805809
}
806810
};

src/test/ui/macros/format-foreign.stderr

+5-16
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,12 @@ error: multiple unused formatting arguments
22
--> $DIR/format-foreign.rs:12:5
33
|
44
12 | println!("%.*3$s %s!/n", "Hello,", "World", 4);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^--------^^-------^^-^^
6+
| | | |
7+
| | | unused
8+
| | unused
9+
| unused
610
|
7-
note: argument never used
8-
--> $DIR/format-foreign.rs:12:30
9-
|
10-
12 | println!("%.*3$s %s!/n", "Hello,", "World", 4);
11-
| ^^^^^^^^
12-
note: argument never used
13-
--> $DIR/format-foreign.rs:12:40
14-
|
15-
12 | println!("%.*3$s %s!/n", "Hello,", "World", 4);
16-
| ^^^^^^^
17-
note: argument never used
18-
--> $DIR/format-foreign.rs:12:49
19-
|
20-
12 | println!("%.*3$s %s!/n", "Hello,", "World", 4);
21-
| ^
2211
= help: `%.*3$s` should be written as `{:.2$}`
2312
= help: `%s` should be written as `{}`
2413
= note: printf formatting not supported; see the documentation for `std::fmt`
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
println!("Test", 123, 456, 789);
13+
14+
println!("Test2",
15+
123,
16+
456,
17+
789
18+
);
19+
20+
println!("Some stuff", UNUSED="args");
21+
22+
println!("Some more $STUFF",
23+
"woo!",
24+
STUFF=
25+
"things"
26+
, UNUSED="args");
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
error: multiple unused formatting arguments
2+
--> $DIR/format-unused-lables.rs:12:5
3+
|
4+
12 | println!("Test", 123, 456, 789);
5+
| ^^^^^^^^^^^^^^^^^---^^---^^---^^
6+
| | | |
7+
| | | unused
8+
| | unused
9+
| unused
10+
|
11+
= note: this error originates in a macro outside of the current crate
12+
13+
error: multiple unused formatting arguments
14+
--> $DIR/format-unused-lables.rs:14:5
15+
|
16+
14 | / println!("Test2",
17+
15 | | 123,
18+
| | --- unused
19+
16 | | 456,
20+
| | --- unused
21+
17 | | 789
22+
| | --- unused
23+
18 | | );
24+
| |______^
25+
|
26+
= note: this error originates in a macro outside of the current crate
27+
28+
error: named argument never used
29+
--> $DIR/format-unused-lables.rs:20:35
30+
|
31+
20 | println!("Some stuff", UNUSED="args");
32+
| ^^^^^^
33+
34+
error: multiple unused formatting arguments
35+
--> $DIR/format-unused-lables.rs:22:5
36+
|
37+
22 | / println!("Some more $STUFF",
38+
23 | | "woo!",
39+
| | ------ unused
40+
24 | | STUFF=
41+
25 | | "things"
42+
| | -------- unused
43+
26 | | , UNUSED="args");
44+
| |_______________________------_^
45+
| |
46+
| unused
47+
|
48+
= help: `$STUFF` should be written as `{STUFF}`
49+
= note: shell formatting not supported; see the documentation for `std::fmt`
50+
= note: this error originates in a macro outside of the current crate
51+
52+
error: aborting due to 4 previous errors
53+

0 commit comments

Comments
 (0)