Skip to content

Commit 62a7324

Browse files
committed
make warnings methods on cx so it's easier to emit them elsewhere too
1 parent b9ce8e5 commit 62a7324

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

compiler/rustc_attr_parsing/src/attributes/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,8 @@ impl<S: Stage> OnDuplicate<S> {
189189
unused: Span,
190190
) {
191191
match self {
192-
OnDuplicate::Warn => cx.emit_lint(
193-
AttributeLintKind::UnusedDuplicate { this: unused, other: used, warning: false },
194-
unused,
195-
),
196-
OnDuplicate::WarnButFutureError => cx.emit_lint(
197-
AttributeLintKind::UnusedDuplicate { this: unused, other: used, warning: true },
198-
unused,
199-
),
192+
OnDuplicate::Warn => cx.warn_unused_duplicate(used, unused),
193+
OnDuplicate::WarnButFutureError => cx.warn_unused_duplicate_future_error(used, unused),
200194
OnDuplicate::Error => {
201195
cx.emit_err(UnusedMultiple {
202196
this: used,

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,32 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
200200
(self.emit_lint)(AttributeLint { id, span, kind: lint });
201201
}
202202

203+
pub(crate) fn warn_unused_duplicate(&mut self, used_span: Span, unused_span: Span) {
204+
self.emit_lint(
205+
AttributeLintKind::UnusedDuplicate {
206+
this: unused_span,
207+
other: used_span,
208+
warning: false,
209+
},
210+
unused_span,
211+
)
212+
}
213+
214+
pub(crate) fn warn_unused_duplicate_future_error(
215+
&mut self,
216+
used_span: Span,
217+
unused_span: Span,
218+
) {
219+
self.emit_lint(
220+
AttributeLintKind::UnusedDuplicate {
221+
this: unused_span,
222+
other: used_span,
223+
warning: true,
224+
},
225+
unused_span,
226+
)
227+
}
228+
203229
pub(crate) fn unknown_key(
204230
&self,
205231
span: Span,

0 commit comments

Comments
 (0)