From 99ae898c575ddaa3a17ae51f651abddf606f99aa Mon Sep 17 00:00:00 2001 From: nxnfufunezn Date: Sat, 17 Oct 2015 01:50:33 +0530 Subject: [PATCH] Add span_lint_note and span_lint_help to the LintContext --- src/librustc/lint/context.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index f5c6cfe2437d..e3eac2e60680 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -435,6 +435,28 @@ pub trait LintContext: Sized { self.lookup_and_emit(lint, Some(span), msg); } + /// Emit a lint and note at the appropriate level, for a particular span. + fn span_lint_note(&self, lint: &'static Lint, span: Span, msg: &str, + note_span: Span, note: &str) { + self.span_lint(lint, span, msg); + if self.current_level(lint) != Level::Allow { + if note_span == span { + self.sess().fileline_note(note_span, note) + } else { + self.sess().span_note(note_span, note) + } + } + } + + /// Emit a lint and help at the appropriate level, for a particular span. + fn span_lint_help(&self, lint: &'static Lint, span: Span, + msg: &str, help: &str) { + self.span_lint(lint, span, msg); + if self.current_level(lint) != Level::Allow { + self.sess().span_help(span, help) + } + } + /// Emit a lint at the appropriate level, with no associated span. fn lint(&self, lint: &'static Lint, msg: &str) { self.lookup_and_emit(lint, None, msg);