Skip to content

Commit 99ae898

Browse files
committed
Add span_lint_note and span_lint_help to the LintContext
1 parent 87e26ef commit 99ae898

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/librustc/lint/context.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,28 @@ pub trait LintContext: Sized {
435435
self.lookup_and_emit(lint, Some(span), msg);
436436
}
437437

438+
/// Emit a lint and note at the appropriate level, for a particular span.
439+
fn span_lint_note(&self, lint: &'static Lint, span: Span, msg: &str,
440+
note_span: Span, note: &str) {
441+
self.span_lint(lint, span, msg);
442+
if self.current_level(lint) != Level::Allow {
443+
if note_span == span {
444+
self.sess().fileline_note(note_span, note)
445+
} else {
446+
self.sess().span_note(note_span, note)
447+
}
448+
}
449+
}
450+
451+
/// Emit a lint and help at the appropriate level, for a particular span.
452+
fn span_lint_help(&self, lint: &'static Lint, span: Span,
453+
msg: &str, help: &str) {
454+
self.span_lint(lint, span, msg);
455+
if self.current_level(lint) != Level::Allow {
456+
self.sess().span_help(span, help)
457+
}
458+
}
459+
438460
/// Emit a lint at the appropriate level, with no associated span.
439461
fn lint(&self, lint: &'static Lint, msg: &str) {
440462
self.lookup_and_emit(lint, None, msg);

0 commit comments

Comments
 (0)