diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2018-01-16 18:11:35 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2018-01-16 18:13:43 -0800 |
| commit | eb3da09333870e94b122d863402d993fb7ecd78f (patch) | |
| tree | e6777c5b95891a25b684e75960fc52adbd6adcc4 | |
| parent | a4660dfea230638dea504c24ca67b49a1d67e1a6 (diff) | |
| download | rust-eb3da09333870e94b122d863402d993fb7ecd78f.tar.gz rust-eb3da09333870e94b122d863402d993fb7ecd78f.zip | |
Add secondary span pointing at the statement (error span)
| -rw-r--r-- | src/libsyntax_ext/format.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/macros/format-foreign.stderr | 3 | ||||
| -rw-r--r-- | src/test/ui/macros/format-unused-lables.stderr | 37 |
3 files changed, 31 insertions, 17 deletions
diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 29280d203c7..a7822414c69 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -814,8 +814,12 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, let (sp, msg) = errs.into_iter().next().unwrap(); cx.ecx.struct_span_err(sp, msg) } else { - cx.ecx.struct_span_err(errs.iter().map(|&(sp, _)| sp).collect::<Vec<Span>>(), - "multiple unused formatting arguments") + let mut diag = cx.ecx.struct_span_err( + errs.iter().map(|&(sp, _)| sp).collect::<Vec<Span>>(), + "multiple unused formatting arguments" + ); + diag.span_label(cx.fmtsp, "multiple unused arguments in this statement"); + diag } }; diff --git a/src/test/ui/macros/format-foreign.stderr b/src/test/ui/macros/format-foreign.stderr index 31804ca4c40..f9852c54773 100644 --- a/src/test/ui/macros/format-foreign.stderr +++ b/src/test/ui/macros/format-foreign.stderr @@ -2,11 +2,12 @@ error: multiple unused formatting arguments --> $DIR/format-foreign.rs:12:30 | 12 | println!("%.*3$s %s!/n", "Hello,", "World", 4); //~ ERROR multiple unused formatting arguments - | ^^^^^^^^ ^^^^^^^ ^ + | -------------------------^^^^^^^^--^^^^^^^--^-- multiple unused arguments in this statement | = 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` + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: argument never used --> $DIR/format-foreign.rs:13:29 diff --git a/src/test/ui/macros/format-unused-lables.stderr b/src/test/ui/macros/format-unused-lables.stderr index 59aed9d8bc6..64ea5626c1d 100644 --- a/src/test/ui/macros/format-unused-lables.stderr +++ b/src/test/ui/macros/format-unused-lables.stderr @@ -2,17 +2,24 @@ error: multiple unused formatting arguments --> $DIR/format-unused-lables.rs:12:22 | 12 | println!("Test", 123, 456, 789); - | ^^^ ^^^ ^^^ + | -----------------^^^--^^^--^^^-- multiple unused arguments in this statement + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: multiple unused formatting arguments --> $DIR/format-unused-lables.rs:16:9 | -16 | 123, //~ ERROR multiple unused formatting arguments - | ^^^ -17 | 456, - | ^^^ -18 | 789 - | ^^^ +15 | / println!("Test2", +16 | | 123, //~ ERROR multiple unused formatting arguments + | | ^^^ +17 | | 456, + | | ^^^ +18 | | 789 + | | ^^^ +19 | | ); + | |______- multiple unused arguments in this statement + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: named argument never used --> $DIR/format-unused-lables.rs:21:35 @@ -23,16 +30,18 @@ error: named argument never used error: multiple unused formatting arguments --> $DIR/format-unused-lables.rs:24:9 | -24 | "woo!", //~ ERROR multiple unused formatting arguments - | ^^^^^^ -25 | STUFF= -26 | "things" - | ^^^^^^^^ -27 | , UNUSED="args"); - | ^^^^^^ +23 | / println!("Some more $STUFF", +24 | | "woo!", //~ ERROR multiple unused formatting arguments + | | ^^^^^^ +25 | | STUFF= +26 | | "things" + | | ^^^^^^^^ +27 | | , UNUSED="args"); + | |_______________________^^^^^^_- multiple unused arguments in this statement | = help: `$STUFF` should be written as `{STUFF}` = note: shell formatting not supported; see the documentation for `std::fmt` + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to 4 previous errors |
