Better copy for lint message

Since x.log(y) is actually implemented as x.ln() / y.ln()
This commit is contained in:
Thiago Arrais 2020-06-15 13:55:12 -03:00
parent 076ec872ce
commit f5596826fa
2 changed files with 5 additions and 5 deletions

View File

@ -618,7 +618,7 @@ fn check_log_division(cx: &LateContext<'_>, expr: &Expr<'_>) {
cx,
SUBOPTIMAL_FLOPS,
expr.span,
"division of logarithms can be calculated more efficiently and accurately",
"log base can be expressed more clearly",
"consider using",
format!("{}.log({})", Sugg::hir(cx, &largs[0], ".."), Sugg::hir(cx, &rargs[0], ".."),),
Applicability::MachineApplicable,

View File

@ -1,4 +1,4 @@
error: division of logarithms can be calculated more efficiently and accurately
error: log base can be expressed more clearly
--> $DIR/floating_point_logbase.rs:7:13
|
LL | let _ = x.ln() / y.ln();
@ -6,19 +6,19 @@ LL | let _ = x.ln() / y.ln();
|
= note: `-D clippy::suboptimal-flops` implied by `-D warnings`
error: division of logarithms can be calculated more efficiently and accurately
error: log base can be expressed more clearly
--> $DIR/floating_point_logbase.rs:8:13
|
LL | let _ = x.log2() / y.log2();
| ^^^^^^^^^^^^^^^^^^^ help: consider using: `x.log(y)`
error: division of logarithms can be calculated more efficiently and accurately
error: log base can be expressed more clearly
--> $DIR/floating_point_logbase.rs:9:13
|
LL | let _ = x.log10() / y.log10();
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.log(y)`
error: division of logarithms can be calculated more efficiently and accurately
error: log base can be expressed more clearly
--> $DIR/floating_point_logbase.rs:10:13
|
LL | let _ = x.log(5f32) / y.log(5f32);