diff options
| author | bors <bors@rust-lang.org> | 2025-07-14 04:29:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-07-14 04:29:53 +0000 |
| commit | cffeac7212f9623bd9915b58618875caa5b7aaa3 (patch) | |
| tree | 24ea6473c87fd031d6c324b92e3d0c4fcb4a96ea | |
| parent | 434fb311f1d29419f0ffee2cfa541ea5a920129b (diff) | |
| parent | 3187aa751a803463ca9c41306b0e663eb80a56d9 (diff) | |
| download | rust-cffeac7212f9623bd9915b58618875caa5b7aaa3.tar.gz rust-cffeac7212f9623bd9915b58618875caa5b7aaa3.zip | |
Auto merge of #143779 - JonathanBrouwer:automatically_derived_parser, r=oli-obk
Port `#[automatically_derived]` to the new attribute parsing infrastructure Ports `#[automatically_derived]` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163 r? `@oli-obk` cc `@jdonszelmann`
| -rw-r--r-- | clippy_lints/src/format_args.rs | 3 | ||||
| -rw-r--r-- | clippy_lints_internal/src/derive_deserialize_allowing_unknown.rs | 2 | ||||
| -rw-r--r-- | clippy_utils/src/lib.rs | 4 |
3 files changed, 5 insertions, 4 deletions
diff --git a/clippy_lints/src/format_args.rs b/clippy_lints/src/format_args.rs index 0c39aae9ca9..16c58ecb455 100644 --- a/clippy_lints/src/format_args.rs +++ b/clippy_lints/src/format_args.rs @@ -30,6 +30,7 @@ use rustc_span::edition::Edition::Edition2021; use rustc_span::{Span, Symbol, sym}; use rustc_trait_selection::infer::TyCtxtInferExt; use rustc_trait_selection::traits::{Obligation, ObligationCause, Selection, SelectionContext}; +use rustc_attr_data_structures::{AttributeKind, find_attr}; declare_clippy_lint! { /// ### What it does @@ -656,7 +657,7 @@ impl<'tcx> FormatArgsExpr<'_, 'tcx> { }; let selection = SelectionContext::new(&infcx).select(&obligation); let derived = if let Ok(Some(Selection::UserDefined(data))) = selection { - tcx.has_attr(data.impl_def_id, sym::automatically_derived) + find_attr!(tcx.get_all_attrs(data.impl_def_id), AttributeKind::AutomaticallyDerived(..)) } else { false }; diff --git a/clippy_lints_internal/src/derive_deserialize_allowing_unknown.rs b/clippy_lints_internal/src/derive_deserialize_allowing_unknown.rs index a1dacd359a0..88b099c477f 100644 --- a/clippy_lints_internal/src/derive_deserialize_allowing_unknown.rs +++ b/clippy_lints_internal/src/derive_deserialize_allowing_unknown.rs @@ -88,7 +88,7 @@ impl<'tcx> LateLintPass<'tcx> for DeriveDeserializeAllowingUnknown { } // Is it derived? - if !cx.tcx.has_attr(item.owner_id, sym::automatically_derived) { + if !find_attr!(cx.tcx.get_all_attrs(item.owner_id), AttributeKind::AutomaticallyDerived(..)) { return; } diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 98b4c183b12..36b91b9c43c 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -1784,9 +1784,9 @@ pub fn in_automatically_derived(tcx: TyCtxt<'_>, id: HirId) -> bool { tcx.hir_parent_owner_iter(id) .filter(|(_, node)| matches!(node, OwnerNode::Item(item) if matches!(item.kind, ItemKind::Impl(_)))) .any(|(id, _)| { - has_attr( + find_attr!( tcx.hir_attrs(tcx.local_def_id_to_hir_id(id.def_id)), - sym::automatically_derived, + AttributeKind::AutomaticallyDerived(..) ) }) } |
