Port rustc_intrinsic to the new attribute parser

This commit is contained in:
Jana Dönszelmann 2026-02-05 14:02:06 +01:00
parent da779a0f01
commit f090e9ce83

View file

@ -1,8 +1,9 @@
use super::EMPTY_LOOP;
use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::{is_in_panic_handler, is_no_std_crate, sym};
use clippy_utils::{is_in_panic_handler, is_no_std_crate};
use rustc_hir::{Block, Expr, ItemKind, Node};
use rustc_hir::attrs::AttributeKind;
use rustc_hir::{Block, Expr, ItemKind, Node, find_attr};
use rustc_lint::LateContext;
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, loop_block: &Block<'_>) {
@ -10,7 +11,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, loop_block: &Block<'_
if let Node::Item(parent_node) = cx.tcx.hir_node(parent_hir_id)
&& matches!(parent_node.kind, ItemKind::Fn { .. })
&& let attrs = cx.tcx.hir_attrs(parent_hir_id)
&& attrs.iter().any(|attr| attr.has_name(sym::rustc_intrinsic))
&& find_attr!(attrs, AttributeKind::RustcIntrinsic)
{
// Intrinsic functions are expanded into an empty loop when lowering the AST
// to simplify the job of later passes which might expect any function to have a body.