diff options
| author | Jana Dönszelmann <jana@donsz.nl> | 2025-06-19 08:26:18 +0200 |
|---|---|---|
| committer | Jana Dönszelmann <jana@donsz.nl> | 2025-06-23 12:21:44 +0200 |
| commit | 73bcf4c117681b95fe591e1d468ac0bf84b8d792 (patch) | |
| tree | a17952757b053fce4cec1ffd65e08f0604d59211 | |
| parent | 82cbc3a35e23a804682922d1c04ac51a00b35137 (diff) | |
| download | rust-73bcf4c117681b95fe591e1d468ac0bf84b8d792.tar.gz rust-73bcf4c117681b95fe591e1d468ac0bf84b8d792.zip | |
make warnings methods on cx so it's easier to emit them elsewhere too
| -rw-r--r-- | compiler/rustc_attr_parsing/src/attributes/mod.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_attr_parsing/src/context.rs | 26 |
2 files changed, 28 insertions, 8 deletions
diff --git a/compiler/rustc_attr_parsing/src/attributes/mod.rs b/compiler/rustc_attr_parsing/src/attributes/mod.rs index 3162c1fc727..bfdd61384e5 100644 --- a/compiler/rustc_attr_parsing/src/attributes/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/mod.rs @@ -189,14 +189,8 @@ impl<S: Stage> OnDuplicate<S> { unused: Span, ) { match self { - OnDuplicate::Warn => cx.emit_lint( - AttributeLintKind::UnusedDuplicate { this: unused, other: used, warning: false }, - unused, - ), - OnDuplicate::WarnButFutureError => cx.emit_lint( - AttributeLintKind::UnusedDuplicate { this: unused, other: used, warning: true }, - unused, - ), + OnDuplicate::Warn => cx.warn_unused_duplicate(used, unused), + OnDuplicate::WarnButFutureError => cx.warn_unused_duplicate_future_error(used, unused), OnDuplicate::Error => { cx.emit_err(UnusedMultiple { this: used, diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index bf289c6aae8..570151eae9d 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -201,6 +201,32 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> { (self.emit_lint)(AttributeLint { id, span, kind: lint }); } + pub(crate) fn warn_unused_duplicate(&mut self, used_span: Span, unused_span: Span) { + self.emit_lint( + AttributeLintKind::UnusedDuplicate { + this: unused_span, + other: used_span, + warning: false, + }, + unused_span, + ) + } + + pub(crate) fn warn_unused_duplicate_future_error( + &mut self, + used_span: Span, + unused_span: Span, + ) { + self.emit_lint( + AttributeLintKind::UnusedDuplicate { + this: unused_span, + other: used_span, + warning: true, + }, + unused_span, + ) + } + pub(crate) fn unknown_key( &self, span: Span, |
