about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
diff options
context:
space:
mode:
authorPavel Grigorenko <GrigorenkoPV@ya.ru>2025-06-15 16:59:11 +0300
committerPavel Grigorenko <GrigorenkoPV@ya.ru>2025-07-04 00:07:56 +0300
commitef4dece2cb52dd14dc4f37a8484fa440a447da14 (patch)
tree510696ebfe3f236b74452512a430b2ed083e0911 /compiler/rustc_lint/src
parent35453a854c4e7eabbfcc4ac4f0095b26ee890dc1 (diff)
downloadrust-ef4dece2cb52dd14dc4f37a8484fa440a447da14.tar.gz
rust-ef4dece2cb52dd14dc4f37a8484fa440a447da14.zip
Port `#[rustc_pass_by_value]` to the new attribute system
Diffstat (limited to 'compiler/rustc_lint/src')
-rw-r--r--compiler/rustc_lint/src/pass_by_value.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_lint/src/pass_by_value.rs b/compiler/rustc_lint/src/pass_by_value.rs
index d85618f664d..d3b3b55dd4c 100644
--- a/compiler/rustc_lint/src/pass_by_value.rs
+++ b/compiler/rustc_lint/src/pass_by_value.rs
@@ -1,8 +1,8 @@
+use rustc_attr_data_structures::{AttributeKind, find_attr};
 use rustc_hir::def::Res;
 use rustc_hir::{self as hir, AmbigArg, GenericArg, PathSegment, QPath, TyKind};
 use rustc_middle::ty;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
-use rustc_span::sym;
 
 use crate::lints::PassByValueDiag;
 use crate::{LateContext, LateLintPass, LintContext};
@@ -45,14 +45,16 @@ impl<'tcx> LateLintPass<'tcx> for PassByValue {
 fn path_for_pass_by_value(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> Option<String> {
     if let TyKind::Path(QPath::Resolved(_, path)) = &ty.kind {
         match path.res {
-            Res::Def(_, def_id) if cx.tcx.has_attr(def_id, sym::rustc_pass_by_value) => {
+            Res::Def(_, def_id)
+                if find_attr!(cx.tcx.get_all_attrs(def_id), AttributeKind::PassByValue(_)) =>
+            {
                 let name = cx.tcx.item_ident(def_id);
                 let path_segment = path.segments.last().unwrap();
                 return Some(format!("{}{}", name, gen_args(cx, path_segment)));
             }
             Res::SelfTyAlias { alias_to: did, is_trait_impl: false, .. } => {
                 if let ty::Adt(adt, args) = cx.tcx.type_of(did).instantiate_identity().kind() {
-                    if cx.tcx.has_attr(adt.did(), sym::rustc_pass_by_value) {
+                    if find_attr!(cx.tcx.get_all_attrs(adt.did()), AttributeKind::PassByValue(_)) {
                         return Some(cx.tcx.def_path_str_with_args(adt.did(), args));
                     }
                 }