@@ -294,8 +294,8 @@ fn check_powi(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, args:
294294 && let Some ( parent) = get_parent_expr ( cx, expr)
295295 {
296296 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
299299 && detect_hypot ( cx, receiver) . is_some ( )
300300 {
301301 return ;
@@ -375,24 +375,10 @@ fn detect_hypot(cx: &LateContext<'_>, receiver: &Expr<'_>) -> Option<String> {
375375 }
376376
377377 // 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
396382 && let ecx = ConstEvalCtxt :: new ( cx)
397383 && let Some ( lvalue) = ecx. eval ( largs_1)
398384 && let Some ( rvalue) = ecx. eval ( rargs_1)
@@ -482,8 +468,8 @@ fn check_mul_add(cx: &LateContext<'_>, expr: &Expr<'_>) {
482468 ) = & expr. kind
483469 {
484470 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
487473 && detect_hypot ( cx, receiver) . is_some ( )
488474 {
489475 return ;
@@ -623,27 +609,13 @@ fn check_custom_abs(cx: &LateContext<'_>, expr: &Expr<'_>) {
623609}
624610
625611fn 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
642614 {
643- return method_name_a . as_str ( ) == method_name_b . as_str ( )
615+ return method_a . name == method_b . name
644616 && 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 ] ) ) ;
647619 }
648620
649621 false
0 commit comments