Rewrite empty attribute lint
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
This commit is contained in:
parent
daf9adbd89
commit
8aad0e6ad9
4 changed files with 4 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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(..)))
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue