diff options
| author | bors <bors@rust-lang.org> | 2015-10-17 08:04:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-10-17 08:04:32 +0000 |
| commit | cd79acf21e28b48795ba3afa55e9f68958c91d6e (patch) | |
| tree | 83542163f454dc58bc8d6a5758d8a957738670be | |
| parent | 32a4bd9ae5afa6781ed4295a76f5a298b73d0a45 (diff) | |
| parent | 72e0e59574a6b1abfdeb723e844d425c893647de (diff) | |
Auto merge of #29109 - nxnfufunezn:master, r=Manishearth
Fixes : #19668 r? @Manishearth
| -rw-r--r-- | src/librustc/lint/context.rs | 22 | ||||
| -rw-r--r-- | src/librustc_lint/builtin.rs | 15 |
2 files changed, 28 insertions, 9 deletions
diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index f5c6cfe2437..e3eac2e6068 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); diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 1bfa41c4db1..a001289b196 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1236,15 +1236,12 @@ impl LateLintPass for DropWithReprExtern { codemap::DUMMY_SP); let self_defn_span = ctx.tcx.map.def_id_span(self_type_did, codemap::DUMMY_SP); - ctx.span_lint(DROP_WITH_REPR_EXTERN, - drop_impl_span, - "implementing Drop adds hidden state to types, \ - possibly conflicting with `#[repr(C)]`"); - // FIXME #19668: could be span_lint_note instead of manual guard. - if ctx.current_level(DROP_WITH_REPR_EXTERN) != Level::Allow { - ctx.sess().span_note(self_defn_span, - "the `#[repr(C)]` attribute is attached here"); - } + ctx.span_lint_note(DROP_WITH_REPR_EXTERN, + drop_impl_span, + "implementing Drop adds hidden state to types, \ + possibly conflicting with `#[repr(C)]`", + self_defn_span, + "the `#[repr(C)]` attribute is attached here"); } } _ => {} |
