Rollup merge of #143252 - JonathanBrouwer:rewrite_empty_attribute, r=jdonszelmann

Rewrite empty attribute lint for new attribute parser

cc `@jdonszelmann`
This commit is contained in:
Matthias Krüger 2025-07-06 15:56:12 +02:00 committed by GitHub
commit 017fe2fb8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 204 additions and 202 deletions

View file

@ -266,7 +266,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
.tcx
.hir_attrs(item.hir_id())
.iter()
.any(|attr| matches!(attr, Attribute::Parsed(AttributeKind::Repr(..))))
.any(|attr| matches!(attr, Attribute::Parsed(AttributeKind::Repr{ .. })))
{
// Do not lint items with a `#[repr]` attribute as their layout may be imposed by an external API.
return;

View file

@ -9,7 +9,7 @@ use clippy_utils::msrvs::{self, Msrv};
use super::REPR_PACKED_WITHOUT_ABI;
pub(super) fn check(cx: &LateContext<'_>, item_span: Span, attrs: &[Attribute], msrv: Msrv) {
if let Some(reprs) = find_attr!(attrs, AttributeKind::Repr(r) => r) {
if let Some(reprs) = find_attr!(attrs, AttributeKind::Repr { reprs, .. } => reprs) {
let packed_span = reprs
.iter()
.find(|(r, _)| matches!(r, ReprAttr::ReprPacked(..)))

View file

@ -99,5 +99,5 @@ fn is_zst<'tcx>(cx: &LateContext<'tcx>, field: &FieldDef, args: ty::GenericArgsR
fn has_c_repr_attr(cx: &LateContext<'_>, hir_id: HirId) -> bool {
let attrs = cx.tcx.hir_attrs(hir_id);
find_attr!(attrs, AttributeKind::Repr(r) if r.iter().any(|(x, _)| *x == ReprAttr::ReprC))
find_attr!(attrs, AttributeKind::Repr { reprs, .. } if reprs.iter().any(|(x, _)| *x == ReprAttr::ReprC))
}

View file

@ -1761,7 +1761,7 @@ pub fn has_attr(attrs: &[hir::Attribute], symbol: Symbol) -> bool {
}
pub fn has_repr_attr(cx: &LateContext<'_>, hir_id: HirId) -> bool {
find_attr!(cx.tcx.hir_attrs(hir_id), AttributeKind::Repr(..))
find_attr!(cx.tcx.hir_attrs(hir_id), AttributeKind::Repr { .. })
}
pub fn any_parent_has_attr(tcx: TyCtxt<'_>, node: HirId, symbol: Symbol) -> bool {