@@ -294,8 +294,8 @@ fn check_powi(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, args:
294
294
&& let Some ( parent) = get_parent_expr ( cx, expr)
295
295
{
296
296
if let Some ( grandparent) = get_parent_expr ( cx, parent)
297
- && let ExprKind :: MethodCall ( PathSegment { ident : method_name , .. } , receiver, ..) = grandparent. kind
298
- && method_name . as_str ( ) == " sqrt"
297
+ && let ExprKind :: MethodCall ( PathSegment { ident : method , .. } , receiver, ..) = grandparent. kind
298
+ && method . name == sym :: sqrt
299
299
&& detect_hypot ( cx, receiver) . is_some ( )
300
300
{
301
301
return ;
@@ -375,24 +375,10 @@ fn detect_hypot(cx: &LateContext<'_>, receiver: &Expr<'_>) -> Option<String> {
375
375
}
376
376
377
377
// check if expression of the form x.powi(2) + y.powi(2)
378
- if let ExprKind :: MethodCall (
379
- PathSegment {
380
- ident : lmethod_name, ..
381
- } ,
382
- largs_0,
383
- [ largs_1, ..] ,
384
- _,
385
- ) = & add_lhs. kind
386
- && let ExprKind :: MethodCall (
387
- PathSegment {
388
- ident : rmethod_name, ..
389
- } ,
390
- rargs_0,
391
- [ rargs_1, ..] ,
392
- _,
393
- ) = & add_rhs. kind
394
- && lmethod_name. as_str ( ) == "powi"
395
- && rmethod_name. as_str ( ) == "powi"
378
+ if let ExprKind :: MethodCall ( PathSegment { ident : lmethod, .. } , largs_0, [ largs_1, ..] , _) = & add_lhs. kind
379
+ && let ExprKind :: MethodCall ( PathSegment { ident : rmethod, .. } , rargs_0, [ rargs_1, ..] , _) = & add_rhs. kind
380
+ && lmethod. name == sym:: powi
381
+ && rmethod. name == sym:: powi
396
382
&& let ecx = ConstEvalCtxt :: new ( cx)
397
383
&& let Some ( lvalue) = ecx. eval ( largs_1)
398
384
&& let Some ( rvalue) = ecx. eval ( rargs_1)
@@ -482,8 +468,8 @@ fn check_mul_add(cx: &LateContext<'_>, expr: &Expr<'_>) {
482
468
) = & expr. kind
483
469
{
484
470
if let Some ( parent) = get_parent_expr ( cx, expr)
485
- && let ExprKind :: MethodCall ( PathSegment { ident : method_name , .. } , receiver, ..) = parent. kind
486
- && method_name . as_str ( ) == " sqrt"
471
+ && let ExprKind :: MethodCall ( PathSegment { ident : method , .. } , receiver, ..) = parent. kind
472
+ && method . name == sym :: sqrt
487
473
&& detect_hypot ( cx, receiver) . is_some ( )
488
474
{
489
475
return ;
@@ -623,27 +609,13 @@ fn check_custom_abs(cx: &LateContext<'_>, expr: &Expr<'_>) {
623
609
}
624
610
625
611
fn are_same_base_logs ( cx : & LateContext < ' _ > , expr_a : & Expr < ' _ > , expr_b : & Expr < ' _ > ) -> bool {
626
- if let ExprKind :: MethodCall (
627
- PathSegment {
628
- ident : method_name_a, ..
629
- } ,
630
- _,
631
- args_a,
632
- _,
633
- ) = expr_a. kind
634
- && let ExprKind :: MethodCall (
635
- PathSegment {
636
- ident : method_name_b, ..
637
- } ,
638
- _,
639
- args_b,
640
- _,
641
- ) = expr_b. kind
612
+ if let ExprKind :: MethodCall ( PathSegment { ident : method_a, .. } , _, args_a, _) = expr_a. kind
613
+ && let ExprKind :: MethodCall ( PathSegment { ident : method_b, .. } , _, args_b, _) = expr_b. kind
642
614
{
643
- return method_name_a . as_str ( ) == method_name_b . as_str ( )
615
+ return method_a . name == method_b . name
644
616
&& args_a. len ( ) == args_b. len ( )
645
- && ( [ "ln" , " log2" , " log10" ] . contains ( & method_name_a . as_str ( ) )
646
- || method_name_a . as_str ( ) == " log" && args_a. len ( ) == 1 && eq_expr_value ( cx, & args_a[ 0 ] , & args_b[ 0 ] ) ) ;
617
+ && ( matches ! ( method_a . name , sym :: ln | sym :: log2 | sym :: log10)
618
+ || method_a . name == sym :: log && args_a. len ( ) == 1 && eq_expr_value ( cx, & args_a[ 0 ] , & args_b[ 0 ] ) ) ;
647
619
}
648
620
649
621
false
0 commit comments