Skip to content

Commit 73bcf4c

Browse files
committed
make warnings methods on cx so it's easier to emit them elsewhere too
1 parent 82cbc3a commit 73bcf4c

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
@@ -201,6 +201,32 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
201201
(self.emit_lint)(AttributeLint { id, span, kind: lint });
202202
}
203203

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

0 commit comments

Comments
 (0)