@@ -11,7 +11,6 @@ declare_tool_lint! {
11
11
/// The `rustc_pass_by_value` lint marks a type with `#[rustc_pass_by_value]` requiring it to always be passed by value.
12
12
/// This is usually used for types that are thin wrappers around references, so there is no benefit to an extra
13
13
/// layer of indirection. (Example: `Ty` which is a reference to a `TyS`)
14
- /// This lint relies on `#[rustc_diagnostic_item]` being available for the target.
15
14
pub rustc:: PASS_BY_VALUE ,
16
15
Warn ,
17
16
"pass by reference of a type flagged as `#[rustc_pass_by_value]`" ,
@@ -52,16 +51,14 @@ fn path_for_pass_by_value(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> Option<Stri
52
51
if let TyKind :: Path ( QPath :: Resolved ( _, path) ) = & ty. kind {
53
52
match path. res {
54
53
Res :: Def ( _, def_id) if has_pass_by_value_attr ( cx, def_id) => {
55
- if let Some ( name) = cx. tcx . get_diagnostic_name ( def_id) {
56
- return Some ( format ! ( "{}{}" , name, gen_args( path. segments. last( ) . unwrap( ) ) ) ) ;
57
- }
54
+ let name = cx. tcx . item_name ( def_id) . to_ident_string ( ) ;
55
+ return Some ( format ! ( "{}{}" , name, gen_args( path. segments. last( ) . unwrap( ) ) ) ) ;
58
56
}
59
57
Res :: SelfTy ( None , Some ( ( did, _) ) ) => {
60
58
if let ty:: Adt ( adt, substs) = cx. tcx . type_of ( did) . kind ( ) {
61
59
if has_pass_by_value_attr ( cx, adt. did ) {
62
- if let Some ( name) = cx. tcx . get_diagnostic_name ( adt. did ) {
63
- return Some ( format ! ( "{}<{}>" , name, substs[ 0 ] ) ) ;
64
- }
60
+ let name = cx. tcx . item_name ( adt. did ) . to_ident_string ( ) ;
61
+ return Some ( format ! ( "{}<{}>" , name, substs[ 0 ] ) ) ;
65
62
}
66
63
}
67
64
}
0 commit comments