Skip to content

Commit 644411e

Browse files
committed
make warnings methods on cx so it's easier to emit them elsewhere too
1 parent 4dc70cb commit 644411e

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
@@ -174,14 +174,8 @@ impl<S: Stage> OnDuplicate<S> {
174174
unused: Span,
175175
) {
176176
match self {
177-
OnDuplicate::Warn => cx.emit_lint(
178-
AttributeLintKind::UnusedDuplicate { this: unused, other: used, warning: false },
179-
unused,
180-
),
181-
OnDuplicate::WarnButFutureError => cx.emit_lint(
182-
AttributeLintKind::UnusedDuplicate { this: unused, other: used, warning: true },
183-
unused,
184-
),
177+
OnDuplicate::Warn => cx.warn_unused_duplicate(used, unused),
178+
OnDuplicate::WarnButFutureError => cx.warn_unused_duplicate_future_error(used, unused),
185179
OnDuplicate::Error => {
186180
cx.emit_err(UnusedMultiple {
187181
this: used,

compiler/rustc_attr_parsing/src/context.rs

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

198+
pub(crate) fn warn_unused_duplicate(&mut self, used_span: Span, unused_span: Span) {
199+
self.emit_lint(
200+
AttributeLintKind::UnusedDuplicate {
201+
this: unused_span,
202+
other: used_span,
203+
warning: false,
204+
},
205+
unused_span,
206+
)
207+
}
208+
209+
pub(crate) fn warn_unused_duplicate_future_error(
210+
&mut self,
211+
used_span: Span,
212+
unused_span: Span,
213+
) {
214+
self.emit_lint(
215+
AttributeLintKind::UnusedDuplicate {
216+
this: unused_span,
217+
other: used_span,
218+
warning: true,
219+
},
220+
unused_span,
221+
)
222+
}
223+
198224
pub(crate) fn unknown_key(
199225
&self,
200226
span: Span,

0 commit comments

Comments
 (0)