@@ -3,34 +3,34 @@ use rustc_hir::{self as hir, AmbigArg, GenericArg, PathSegment, QPath, TyKind, f
33use rustc_middle:: ty;
44use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
55
6- use crate :: lints:: PassByValueDiag ;
6+ use crate :: lints:: DisallowedPassByRefDiag ;
77use crate :: { LateContext , LateLintPass , LintContext } ;
88
99declare_tool_lint ! {
10- /// The `rustc_pass_by_value ` lint marks a type with `#[rustc_pass_by_value]` requiring it to
11- /// always be passed by value. This is usually used for types that are thin wrappers around
12- /// references, so there is no benefit to an extra layer of indirection. (Example: `Ty` which
13- /// is a reference to an `Interned<TyKind>`)
14- pub rustc:: PASS_BY_VALUE ,
10+ /// The `disallowed_pass_by_ref ` lint detects if types marked with `#[rustc_pass_by_value]` are
11+ /// passed by reference. Types with this marker are usually thin wrappers around references, so
12+ /// there is no benefit to an extra layer of indirection. (Example: `Ty` which is a reference
13+ /// to an `Interned<TyKind>`)
14+ pub rustc:: DISALLOWED_PASS_BY_REF ,
1515 Warn ,
1616 "pass by reference of a type flagged as `#[rustc_pass_by_value]`" ,
1717 report_in_external_macro: true
1818}
1919
20- declare_lint_pass ! ( PassByValue => [ PASS_BY_VALUE ] ) ;
20+ declare_lint_pass ! ( DisallowedPassByRef => [ DISALLOWED_PASS_BY_REF ] ) ;
2121
22- impl < ' tcx > LateLintPass < ' tcx > for PassByValue {
22+ impl < ' tcx > LateLintPass < ' tcx > for DisallowedPassByRef {
2323 fn check_ty ( & mut self , cx : & LateContext < ' _ > , ty : & ' tcx hir:: Ty < ' tcx , AmbigArg > ) {
2424 match & ty. kind {
2525 TyKind :: Ref ( _, hir:: MutTy { ty : inner_ty, mutbl : hir:: Mutability :: Not } ) => {
2626 if cx. tcx . trait_impl_of_assoc ( ty. hir_id . owner . to_def_id ( ) ) . is_some ( ) {
2727 return ;
2828 }
29- if let Some ( t) = path_for_pass_by_value ( cx, inner_ty) {
29+ if let Some ( t) = path_for_rustc_pass_by_value ( cx, inner_ty) {
3030 cx. emit_span_lint (
31- PASS_BY_VALUE ,
31+ DISALLOWED_PASS_BY_REF ,
3232 ty. span ,
33- PassByValueDiag { ty : t, suggestion : ty. span } ,
33+ DisallowedPassByRefDiag { ty : t, suggestion : ty. span } ,
3434 ) ;
3535 }
3636 }
@@ -39,7 +39,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByValue {
3939 }
4040}
4141
42- fn path_for_pass_by_value ( cx : & LateContext < ' _ > , ty : & hir:: Ty < ' _ > ) -> Option < String > {
42+ fn path_for_rustc_pass_by_value ( cx : & LateContext < ' _ > , ty : & hir:: Ty < ' _ > ) -> Option < String > {
4343 if let TyKind :: Path ( QPath :: Resolved ( _, path) ) = & ty. kind {
4444 match path. res {
4545 Res :: Def ( _, def_id) if find_attr ! ( cx. tcx, def_id, RustcPassByValue ( _) ) => {
0 commit comments