@@ -573,12 +573,17 @@ fn check_custom_abs(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
573
573
}
574
574
}
575
575
576
- fn are_same_base_logs ( expr_a : & Expr < ' _ > , expr_b : & Expr < ' _ > ) -> bool {
576
+ fn are_same_base_logs ( cx : & LateContext < ' _ , ' _ > , expr_a : & Expr < ' _ > , expr_b : & Expr < ' _ > ) -> bool {
577
577
if_chain ! {
578
- if let ExprKind :: MethodCall ( PathSegment { ident: method_name_a, .. } , _, _ ) = expr_a. kind;
579
- if let ExprKind :: MethodCall ( PathSegment { ident: method_name_b, .. } , _, _ ) = expr_b. kind;
578
+ if let ExprKind :: MethodCall ( PathSegment { ident: method_name_a, .. } , _, ref args_a ) = expr_a. kind;
579
+ if let ExprKind :: MethodCall ( PathSegment { ident: method_name_b, .. } , _, ref args_b ) = expr_b. kind;
580
580
then {
581
- return method_name_a. as_str( ) == method_name_b. as_str( ) && [ "ln" , "log2" , "log10" ] . contains( &&* method_name_a. as_str( ) ) ;
581
+ return method_name_a. as_str( ) == method_name_b. as_str( ) &&
582
+ args_a. len( ) == args_b. len( ) &&
583
+ (
584
+ [ "ln" , "log2" , "log10" ] . contains( &&* method_name_a. as_str( ) ) ||
585
+ method_name_a. as_str( ) == "log" && args_a. len( ) == 2 && are_exprs_equal( cx, & args_a[ 1 ] , & args_b[ 1 ] )
586
+ ) ;
582
587
}
583
588
}
584
589
@@ -595,7 +600,7 @@ fn check_logbase(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
595
600
lhs,
596
601
rhs,
597
602
) = & expr. kind;
598
- if are_same_base_logs( lhs, rhs) ;
603
+ if are_same_base_logs( cx , lhs, rhs) ;
599
604
if let ExprKind :: MethodCall ( _, _, ref largs) = lhs. kind;
600
605
if let ExprKind :: MethodCall ( _, _, ref rargs) = rhs. kind;
601
606
then {
0 commit comments