@@ -76,6 +76,7 @@ enum LintKind {
76
76
Big ,
77
77
}
78
78
79
+ #[ derive( Clone , Copy , PartialEq ) ]
79
80
enum Prefix {
80
81
From ,
81
82
To ,
@@ -94,8 +95,8 @@ impl LintKind {
94
95
}
95
96
}
96
97
97
- fn as_name ( & self , prefix : & Prefix ) -> & str {
98
- let index = usize:: from ( matches ! ( prefix, Prefix :: To ) ) ;
98
+ fn as_name ( & self , prefix : Prefix ) -> & str {
99
+ let index = usize:: from ( prefix == Prefix :: To ) ;
99
100
100
101
match self {
101
102
LintKind :: Host => HOST_NAMES [ index] ,
@@ -116,7 +117,7 @@ impl LateLintPass<'_> for EndianBytes {
116
117
if args. is_empty( ) ;
117
118
let ty = cx. typeck_results( ) . expr_ty( receiver) ;
118
119
if ty. is_primitive_ty( ) ;
119
- if maybe_lint_endian_bytes( cx, expr, & Prefix :: To , method_name. ident. name, ty) ;
120
+ if maybe_lint_endian_bytes( cx, expr, Prefix :: To , method_name. ident. name, ty) ;
120
121
then {
121
122
return ;
122
123
}
@@ -130,13 +131,13 @@ impl LateLintPass<'_> for EndianBytes {
130
131
let ty = cx. typeck_results( ) . expr_ty( expr) ;
131
132
if ty. is_primitive_ty( ) ;
132
133
then {
133
- maybe_lint_endian_bytes( cx, expr, & Prefix :: From , * function_name, ty) ;
134
+ maybe_lint_endian_bytes( cx, expr, Prefix :: From , * function_name, ty) ;
134
135
}
135
136
}
136
137
}
137
138
}
138
139
139
- fn maybe_lint_endian_bytes ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > , prefix : & Prefix , name : Symbol , ty : Ty < ' _ > ) -> bool {
140
+ fn maybe_lint_endian_bytes ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > , prefix : Prefix , name : Symbol , ty : Ty < ' _ > ) -> bool {
140
141
let ne = LintKind :: Host . as_name ( prefix) ;
141
142
let le = LintKind :: Little . as_name ( prefix) ;
142
143
let be = LintKind :: Big . as_name ( prefix) ;
@@ -200,13 +201,9 @@ fn maybe_lint_endian_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, prefix: &Prefi
200
201
expr. span ,
201
202
& format ! (
202
203
"usage of the {}`{ty}::{}`{}" ,
203
- if matches!( prefix, Prefix :: From ) {
204
- "function "
205
- } else {
206
- ""
207
- } ,
204
+ if prefix == Prefix :: From { "function " } else { "" } ,
208
205
lint. as_name( prefix) ,
209
- if matches! ( prefix, Prefix :: To ) { " method" } else { "" } ,
206
+ if prefix == Prefix :: To { " method" } else { "" } ,
210
207
) ,
211
208
move |diag| {
212
209
if let Some ( help) = help {
0 commit comments