Skip to content

Commit a427efb

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

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

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

0 commit comments

Comments
 (0)