diff options
| author | Jana Dönszelmann <jana@donsz.nl> | 2025-08-16 18:04:58 +0200 |
|---|---|---|
| committer | Jana Dönszelmann <jana@donsz.nl> | 2025-08-21 13:15:30 +0200 |
| commit | 2158e2d4d7b2722325de01530296c4e93297c06f (patch) | |
| tree | d18a87ad2bc0cdb0fd5cabf8f59ab2eb6d7beb7f /compiler/rustc_attr_parsing/src/lints.rs | |
| parent | 9be8effb3f7636521d0d177fe23504bd69094ba3 (diff) | |
| download | rust-2158e2d4d7b2722325de01530296c4e93297c06f.tar.gz rust-2158e2d4d7b2722325de01530296c4e93297c06f.zip | |
refactor target checking, move out of context.rs and rename MaybeWarn to Policy
Diffstat (limited to 'compiler/rustc_attr_parsing/src/lints.rs')
| -rw-r--r-- | compiler/rustc_attr_parsing/src/lints.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rustc_attr_parsing/src/lints.rs b/compiler/rustc_attr_parsing/src/lints.rs index 2813fef3148..7030f28f23c 100644 --- a/compiler/rustc_attr_parsing/src/lints.rs +++ b/compiler/rustc_attr_parsing/src/lints.rs @@ -1,3 +1,5 @@ +use std::borrow::Cow; + use rustc_errors::{DiagArgValue, LintEmitter}; use rustc_hir::lints::{AttributeLint, AttributeLintKind}; use rustc_hir::{HirId, Target}; @@ -35,12 +37,12 @@ pub fn emit_attribute_lint<L: LintEmitter>(lint: &AttributeLint<HirId>, lint_emi *first_span, session_diagnostics::EmptyAttributeList { attr_span: *first_span }, ), - &AttributeLintKind::InvalidTarget { name, target, ref applied, only } => lint_emitter + AttributeLintKind::InvalidTarget { name, target, applied, only } => lint_emitter .emit_node_span_lint( // This check is here because `deprecated` had its own lint group and removing this would be a breaking change - if name == sym::deprecated + if name.segments[0].name == sym::deprecated && ![Target::Closure, Target::Expression, Target::Statement, Target::Arm] - .contains(&target) + .contains(target) { rustc_session::lint::builtin::USELESS_DEPRECATED } else { @@ -51,7 +53,9 @@ pub fn emit_attribute_lint<L: LintEmitter>(lint: &AttributeLint<HirId>, lint_emi session_diagnostics::InvalidTargetLint { name, target: target.plural_name(), - applied: applied.clone(), + applied: DiagArgValue::StrListSepByAnd( + applied.into_iter().map(|i| Cow::Owned(i.to_string())).collect(), + ), only, attr_span: *span, }, |
