@@ -882,12 +882,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
882
882
let ty = cx. tcx. type_of( def_id) ;
883
883
let is_copy = is_copy( cx, ty) ;
884
884
for & ( ref conv, self_kinds) in & CONVENTIONS {
885
- if_chain! {
886
- if conv. check( & name. as_str( ) ) ;
885
+ if conv. check( & name. as_str( ) ) {
887
886
if !self_kinds
888
- . iter( )
889
- . any( |k| k. matches( cx, first_arg_ty, first_arg, self_ty, is_copy, & implitem. generics) ) ;
890
- then {
887
+ . iter( )
888
+ . any( |k| k. matches( cx, first_arg_ty, first_arg, self_ty, is_copy, & implitem. generics) ) {
891
889
let lint = if item. vis. node. is_pub( ) {
892
890
WRONG_PUB_SELF_CONVENTION
893
891
} else {
@@ -904,6 +902,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
904
902
. collect:: <Vec <_>>( )
905
903
. join( " or " ) ) ) ;
906
904
}
905
+
906
+ // Only check the first convention to match (CONVENTIONS should be listed from most to least specific)
907
+ break ;
907
908
}
908
909
}
909
910
@@ -1183,8 +1184,8 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
1183
1184
Applicability :: MaybeIncorrect ,
1184
1185
) ;
1185
1186
db. span_suggestion_with_applicability (
1186
- expr. span ,
1187
- "or try being explicit about what type to clone" ,
1187
+ expr. span ,
1188
+ "or try being explicit about what type to clone" ,
1188
1189
explicit,
1189
1190
Applicability :: MaybeIncorrect ,
1190
1191
) ;
@@ -2067,12 +2068,13 @@ enum Convention {
2067
2068
}
2068
2069
2069
2070
#[ rustfmt:: skip]
2070
- const CONVENTIONS : [ ( Convention , & [ SelfKind ] ) ; 6 ] = [
2071
+ const CONVENTIONS : [ ( Convention , & [ SelfKind ] ) ; 7 ] = [
2071
2072
( Convention :: Eq ( "new" ) , & [ SelfKind :: No ] ) ,
2072
2073
( Convention :: StartsWith ( "as_" ) , & [ SelfKind :: Ref , SelfKind :: RefMut ] ) ,
2073
2074
( Convention :: StartsWith ( "from_" ) , & [ SelfKind :: No ] ) ,
2074
2075
( Convention :: StartsWith ( "into_" ) , & [ SelfKind :: Value ] ) ,
2075
2076
( Convention :: StartsWith ( "is_" ) , & [ SelfKind :: Ref , SelfKind :: No ] ) ,
2077
+ ( Convention :: Eq ( "to_mut" ) , & [ SelfKind :: RefMut ] ) ,
2076
2078
( Convention :: StartsWith ( "to_" ) , & [ SelfKind :: Ref ] ) ,
2077
2079
] ;
2078
2080
0 commit comments