diff options
| author | kennytm <kennytm@gmail.com> | 2018-01-18 01:57:25 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-18 01:57:25 +0800 |
| commit | 35bf7f844cf516b0cf0e45e0f813ea3cd9f43624 (patch) | |
| tree | 78f32e6664be74a0a4092ef7f2693cf1b991a24c /src/libsyntax/ext | |
| parent | b2c5484c1790844059a6b42554cb574b671b5189 (diff) | |
| parent | eb3da09333870e94b122d863402d993fb7ecd78f (diff) | |
| download | rust-35bf7f844cf516b0cf0e45e0f813ea3cd9f43624.tar.gz rust-35bf7f844cf516b0cf0e45e0f813ea3cd9f43624.zip | |
Rollup merge of #47481 - estebank:unused-args, r=arielb1
Point at unused arguments for format string Avoid overlapping spans by only pointing at the arguments that are not being used in the argument string. Enable libsyntax to have diagnostics with multiple primary spans by accepting `Into<MultiSpan>` instead of `Span`. Partially addresses #41850.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 0d3be28ffef..612d8501fb2 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -13,7 +13,7 @@ pub use self::SyntaxExtension::*; use ast::{self, Attribute, Name, PatKind, MetaItem}; use attr::HasAttrs; use codemap::{self, CodeMap, Spanned, respan}; -use syntax_pos::{Span, DUMMY_SP}; +use syntax_pos::{Span, MultiSpan, DUMMY_SP}; use errors::DiagnosticBuilder; use ext::expand::{self, Expansion, Invocation}; use ext::hygiene::{Mark, SyntaxContext}; @@ -754,22 +754,22 @@ impl<'a> ExtCtxt<'a> { last_macro } - pub fn struct_span_warn(&self, - sp: Span, - msg: &str) - -> DiagnosticBuilder<'a> { + pub fn struct_span_warn<S: Into<MultiSpan>>(&self, + sp: S, + msg: &str) + -> DiagnosticBuilder<'a> { self.parse_sess.span_diagnostic.struct_span_warn(sp, msg) } - pub fn struct_span_err(&self, - sp: Span, - msg: &str) - -> DiagnosticBuilder<'a> { + pub fn struct_span_err<S: Into<MultiSpan>>(&self, + sp: S, + msg: &str) + -> DiagnosticBuilder<'a> { self.parse_sess.span_diagnostic.struct_span_err(sp, msg) } - pub fn struct_span_fatal(&self, - sp: Span, - msg: &str) - -> DiagnosticBuilder<'a> { + pub fn struct_span_fatal<S: Into<MultiSpan>>(&self, + sp: S, + msg: &str) + -> DiagnosticBuilder<'a> { self.parse_sess.span_diagnostic.struct_span_fatal(sp, msg) } @@ -785,7 +785,7 @@ impl<'a> ExtCtxt<'a> { /// in most cases one can construct a dummy expression/item to /// substitute; we never hit resolve/type-checking so the dummy /// value doesn't have to match anything) - pub fn span_fatal(&self, sp: Span, msg: &str) -> ! { + pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ! { panic!(self.parse_sess.span_diagnostic.span_fatal(sp, msg)); } @@ -794,20 +794,20 @@ impl<'a> ExtCtxt<'a> { /// /// Compilation will be stopped in the near future (at the end of /// the macro expansion phase). - pub fn span_err(&self, sp: Span, msg: &str) { + pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: &str) { self.parse_sess.span_diagnostic.span_err(sp, msg); } - pub fn mut_span_err(&self, sp: Span, msg: &str) + pub fn mut_span_err<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> DiagnosticBuilder<'a> { self.parse_sess.span_diagnostic.mut_span_err(sp, msg) } - pub fn span_warn(&self, sp: Span, msg: &str) { + pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: &str) { self.parse_sess.span_diagnostic.span_warn(sp, msg); } - pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! { + pub fn span_unimpl<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ! { self.parse_sess.span_diagnostic.span_unimpl(sp, msg); } - pub fn span_bug(&self, sp: Span, msg: &str) -> ! { + pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ! { self.parse_sess.span_diagnostic.span_bug(sp, msg); } pub fn trace_macros_diag(&mut self) { |
