Skip to content

Commit cd79acf

Browse files
committed
Auto merge of #29109 - nxnfufunezn:master, r=Manishearth
Fixes : #19668 r? @Manishearth
2 parents 32a4bd9 + 72e0e59 commit cd79acf

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
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);

src/librustc_lint/builtin.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,15 +1236,12 @@ impl LateLintPass for DropWithReprExtern {
12361236
codemap::DUMMY_SP);
12371237
let self_defn_span = ctx.tcx.map.def_id_span(self_type_did,
12381238
codemap::DUMMY_SP);
1239-
ctx.span_lint(DROP_WITH_REPR_EXTERN,
1240-
drop_impl_span,
1241-
"implementing Drop adds hidden state to types, \
1242-
possibly conflicting with `#[repr(C)]`");
1243-
// FIXME #19668: could be span_lint_note instead of manual guard.
1244-
if ctx.current_level(DROP_WITH_REPR_EXTERN) != Level::Allow {
1245-
ctx.sess().span_note(self_defn_span,
1246-
"the `#[repr(C)]` attribute is attached here");
1247-
}
1239+
ctx.span_lint_note(DROP_WITH_REPR_EXTERN,
1240+
drop_impl_span,
1241+
"implementing Drop adds hidden state to types, \
1242+
possibly conflicting with `#[repr(C)]`",
1243+
self_defn_span,
1244+
"the `#[repr(C)]` attribute is attached here");
12481245
}
12491246
}
12501247
_ => {}

0 commit comments

Comments
 (0)