Consolidate the accuracy and efficiency lints

Merge the accuracy and efficiency lints into a single lint that
checks for improvements to accuracy, efficiency and readability
of floating-point expressions.
This commit is contained in:
Krishna Veera Reddy 2019-12-14 20:10:23 -08:00 committed by Krishna Sai Veera Reddy
parent c636c6a55b
commit 1f4f357bf5
6 changed files with 76 additions and 105 deletions

View File

@ -1169,7 +1169,6 @@ Released 2018-09-13
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond [`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
[`implicit_hasher`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_hasher [`implicit_hasher`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_hasher
[`implicit_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_return [`implicit_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_return
[`inaccurate_floating_point_computation`]: https://rust-lang.github.io/rust-clippy/master/index.html#inaccurate_floating_point_computation
[`inconsistent_digit_grouping`]: https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_digit_grouping [`inconsistent_digit_grouping`]: https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_digit_grouping
[`indexing_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing [`indexing_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing
[`ineffective_bit_mask`]: https://rust-lang.github.io/rust-clippy/master/index.html#ineffective_bit_mask [`ineffective_bit_mask`]: https://rust-lang.github.io/rust-clippy/master/index.html#ineffective_bit_mask

View File

@ -13,11 +13,12 @@ use std::f32::consts as f32_consts;
use std::f64::consts as f64_consts; use std::f64::consts as f64_consts;
declare_clippy_lint! { declare_clippy_lint! {
/// **What it does:** Looks for numerically unstable floating point /// **What it does:** Looks for floating-point expressions that
/// computations and suggests better alternatives. /// can be expressed using built-in methods to improve accuracy,
/// performance and/or succinctness.
/// ///
/// **Why is this bad?** Numerically unstable floating point computations /// **Why is this bad?** Negatively affects accuracy, performance
/// cause rounding errors to magnify and distorts the results strongly. /// and/or readability.
/// ///
/// **Known problems:** None /// **Known problems:** None
/// ///
@ -26,59 +27,43 @@ declare_clippy_lint! {
/// ```rust /// ```rust
/// use std::f32::consts::E; /// use std::f32::consts::E;
/// ///
/// let a = 1f32.log(2.0); /// let a = 3f32;
/// let b = 1f32.log(10.0); /// let _ = (2f32).powf(a);
/// let c = 1f32.log(E); /// let _ = E.powf(a);
/// let _ = a.powf(1.0 / 2.0);
/// let _ = a.powf(1.0 / 3.0);
/// let _ = a.log(2.0);
/// let _ = a.log(10.0);
/// let _ = a.log(E);
/// let _ = (1.0 + a).ln();
/// let _ = a.exp() - 1.0;
/// ``` /// ```
/// ///
/// is better expressed as /// is better expressed as
/// ///
/// ```rust /// ```rust
/// let a = 1f32.log2();
/// let b = 1f32.log10();
/// let c = 1f32.ln();
/// ```
pub INACCURATE_FLOATING_POINT_COMPUTATION,
nursery,
"checks for numerically unstable floating point computations"
}
declare_clippy_lint! {
/// **What it does:** Looks for inefficient floating point computations
/// and suggests faster alternatives.
///
/// **Why is this bad?** Lower performance.
///
/// **Known problems:** None
///
/// **Example:**
///
/// ```rust
/// use std::f32::consts::E; /// use std::f32::consts::E;
/// ///
/// let a = (2f32).powf(3.0); /// let a = 3f32;
/// let c = E.powf(3.0); /// let _ = a.exp2();
/// let _ = a.exp();
/// let _ = a.sqrt();
/// let _ = a.cbrt();
/// let _ = a.log2();
/// let _ = a.log10();
/// let _ = a.ln();
/// let _ = a.ln_1p();
/// let _ = a.exp_m1();
/// ``` /// ```
/// pub FLOATING_POINT_IMPROVEMENTS,
/// is better expressed as
///
/// ```rust
/// let a = (3f32).exp2();
/// let b = (3f32).exp();
/// ```
pub SLOW_FLOATING_POINT_COMPUTATION,
nursery, nursery,
"checks for inefficient floating point computations" "looks for improvements to floating-point expressions"
} }
declare_lint_pass!(FloatingPointArithmetic => [ declare_lint_pass!(FloatingPointArithmetic => [FLOATING_POINT_IMPROVEMENTS]);
INACCURATE_FLOATING_POINT_COMPUTATION,
SLOW_FLOATING_POINT_COMPUTATION
]);
fn check_log_base(cx: &LateContext<'_, '_>, expr: &Expr, args: &HirVec<Expr>) { fn check_log_base(cx: &LateContext<'_, '_>, expr: &Expr, args: &HirVec<Expr>) {
let recv = &args[0]; let arg = sugg::Sugg::hir(cx, &args[0], "..").maybe_par();
let arg = sugg::Sugg::hir(cx, recv, "..").maybe_par();
if let Some((value, _)) = constant(cx, cx.tables, &args[1]) { if let Some((value, _)) = constant(cx, cx.tables, &args[1]) {
let method; let method;
@ -95,7 +80,7 @@ fn check_log_base(cx: &LateContext<'_, '_>, expr: &Expr, args: &HirVec<Expr>) {
span_lint_and_sugg( span_lint_and_sugg(
cx, cx,
INACCURATE_FLOATING_POINT_COMPUTATION, FLOATING_POINT_IMPROVEMENTS,
expr.span, expr.span,
"logarithm for bases 2, 10 and e can be computed more accurately", "logarithm for bases 2, 10 and e can be computed more accurately",
"consider using", "consider using",
@ -118,7 +103,7 @@ fn check_ln1p(cx: &LateContext<'_, '_>, expr: &Expr, args: &HirVec<Expr>) {
span_lint_and_sugg( span_lint_and_sugg(
cx, cx,
INACCURATE_FLOATING_POINT_COMPUTATION, FLOATING_POINT_IMPROVEMENTS,
expr.span, expr.span,
"ln(1 + x) can be computed more accurately", "ln(1 + x) can be computed more accurately",
"consider using", "consider using",
@ -144,9 +129,9 @@ fn check_powf(cx: &LateContext<'_, '_>, expr: &Expr, args: &HirVec<Expr>) {
span_lint_and_sugg( span_lint_and_sugg(
cx, cx,
SLOW_FLOATING_POINT_COMPUTATION, FLOATING_POINT_IMPROVEMENTS,
expr.span, expr.span,
"exponent for bases 2 and e can be computed more efficiently", "exponent for bases 2 and e can be computed more accurately",
"consider using", "consider using",
format!("{}.{}()", sugg::Sugg::hir(cx, &args[1], "..").maybe_par(), method), format!("{}.{}()", sugg::Sugg::hir(cx, &args[1], "..").maybe_par(), method),
Applicability::MachineApplicable, Applicability::MachineApplicable,
@ -159,10 +144,10 @@ fn check_powf(cx: &LateContext<'_, '_>, expr: &Expr, args: &HirVec<Expr>) {
let method; let method;
if F32(1.0 / 2.0) == value || F64(1.0 / 2.0) == value { if F32(1.0 / 2.0) == value || F64(1.0 / 2.0) == value {
help = "square-root of a number can be computer more efficiently"; help = "square-root of a number can be computed more efficiently and accurately";
method = "sqrt"; method = "sqrt";
} else if F32(1.0 / 3.0) == value || F64(1.0 / 3.0) == value { } else if F32(1.0 / 3.0) == value || F64(1.0 / 3.0) == value {
help = "cube-root of a number can be computer more efficiently"; help = "cube-root of a number can be computed more accurately";
method = "cbrt"; method = "cbrt";
} else { } else {
return; return;
@ -170,7 +155,7 @@ fn check_powf(cx: &LateContext<'_, '_>, expr: &Expr, args: &HirVec<Expr>) {
span_lint_and_sugg( span_lint_and_sugg(
cx, cx,
SLOW_FLOATING_POINT_COMPUTATION, FLOATING_POINT_IMPROVEMENTS,
expr.span, expr.span,
help, help,
"consider using", "consider using",
@ -194,7 +179,7 @@ fn check_expm1(cx: &LateContext<'_, '_>, expr: &Expr) {
then { then {
span_lint_and_sugg( span_lint_and_sugg(
cx, cx,
INACCURATE_FLOATING_POINT_COMPUTATION, FLOATING_POINT_IMPROVEMENTS,
expr.span, expr.span,
"(e.pow(x) - 1) can be computed more accurately", "(e.pow(x) - 1) can be computed more accurately",
"consider using", "consider using",

View File

@ -1649,8 +1649,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
LintId::of(&attrs::EMPTY_LINE_AFTER_OUTER_ATTR), LintId::of(&attrs::EMPTY_LINE_AFTER_OUTER_ATTR),
LintId::of(&fallible_impl_from::FALLIBLE_IMPL_FROM), LintId::of(&fallible_impl_from::FALLIBLE_IMPL_FROM),
LintId::of(&floating_point_arithmetic::INACCURATE_FLOATING_POINT_COMPUTATION), LintId::of(&floating_point_arithmetic::FLOATING_POINT_IMPROVEMENTS),
LintId::of(&floating_point_arithmetic::SLOW_FLOATING_POINT_COMPUTATION),
LintId::of(&missing_const_for_fn::MISSING_CONST_FOR_FN), LintId::of(&missing_const_for_fn::MISSING_CONST_FOR_FN),
LintId::of(&mul_add::MANUAL_MUL_ADD), LintId::of(&mul_add::MANUAL_MUL_ADD),
LintId::of(&mutable_debug_assertion::DEBUG_ASSERT_WITH_MUT_CALL), LintId::of(&mutable_debug_assertion::DEBUG_ASSERT_WITH_MUT_CALL),

View File

@ -749,13 +749,6 @@ pub const ALL_LINTS: [Lint; 357] = [
deprecation: None, deprecation: None,
module: "implicit_return", module: "implicit_return",
}, },
Lint {
name: "inaccurate_floating_point_computation",
group: "nursery",
desc: "checks for numerically unstable floating point computations",
deprecation: None,
module: "floating_point_arithmetic",
},
Lint { Lint {
name: "inconsistent_digit_grouping", name: "inconsistent_digit_grouping",
group: "style", group: "style",

View File

@ -1,8 +1,5 @@
#![allow(dead_code)] #![allow(dead_code)]
#![warn( #![warn(clippy::floating_point_improvements)]
clippy::inaccurate_floating_point_computation,
clippy::slow_floating_point_computation
)]
const TWO: f32 = 2.0; const TWO: f32 = 2.0;
const E: f32 = std::f32::consts::E; const E: f32 = std::f32::consts::E;

View File

@ -1,171 +1,169 @@
error: logarithm for bases 2, 10 and e can be computed more accurately error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:12:13 --> $DIR/floating_point_arithmetic.rs:9:13
| |
LL | let _ = x.log(2f32); LL | let _ = x.log(2f32);
| ^^^^^^^^^^^ help: consider using: `x.log2()` | ^^^^^^^^^^^ help: consider using: `x.log2()`
| |
= note: `-D clippy::inaccurate-floating-point-computation` implied by `-D warnings` = note: `-D clippy::floating-point-improvements` implied by `-D warnings`
error: logarithm for bases 2, 10 and e can be computed more accurately error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:13:13 --> $DIR/floating_point_arithmetic.rs:10:13
| |
LL | let _ = x.log(10f32); LL | let _ = x.log(10f32);
| ^^^^^^^^^^^^ help: consider using: `x.log10()` | ^^^^^^^^^^^^ help: consider using: `x.log10()`
error: logarithm for bases 2, 10 and e can be computed more accurately error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:14:13 --> $DIR/floating_point_arithmetic.rs:11:13
| |
LL | let _ = x.log(std::f32::consts::E); LL | let _ = x.log(std::f32::consts::E);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()`
error: logarithm for bases 2, 10 and e can be computed more accurately error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:15:13 --> $DIR/floating_point_arithmetic.rs:12:13
| |
LL | let _ = x.log(TWO); LL | let _ = x.log(TWO);
| ^^^^^^^^^^ help: consider using: `x.log2()` | ^^^^^^^^^^ help: consider using: `x.log2()`
error: logarithm for bases 2, 10 and e can be computed more accurately error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:16:13 --> $DIR/floating_point_arithmetic.rs:13:13
| |
LL | let _ = x.log(E); LL | let _ = x.log(E);
| ^^^^^^^^ help: consider using: `x.ln()` | ^^^^^^^^ help: consider using: `x.ln()`
error: logarithm for bases 2, 10 and e can be computed more accurately error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:19:13 --> $DIR/floating_point_arithmetic.rs:16:13
| |
LL | let _ = x.log(2f64); LL | let _ = x.log(2f64);
| ^^^^^^^^^^^ help: consider using: `x.log2()` | ^^^^^^^^^^^ help: consider using: `x.log2()`
error: logarithm for bases 2, 10 and e can be computed more accurately error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:20:13 --> $DIR/floating_point_arithmetic.rs:17:13
| |
LL | let _ = x.log(10f64); LL | let _ = x.log(10f64);
| ^^^^^^^^^^^^ help: consider using: `x.log10()` | ^^^^^^^^^^^^ help: consider using: `x.log10()`
error: logarithm for bases 2, 10 and e can be computed more accurately error: logarithm for bases 2, 10 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:21:13 --> $DIR/floating_point_arithmetic.rs:18:13
| |
LL | let _ = x.log(std::f64::consts::E); LL | let _ = x.log(std::f64::consts::E);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()`
error: ln(1 + x) can be computed more accurately error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:26:13 --> $DIR/floating_point_arithmetic.rs:23:13
| |
LL | let _ = (1.0 + x).ln(); LL | let _ = (1.0 + x).ln();
| ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()`
error: ln(1 + x) can be computed more accurately error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:27:13 --> $DIR/floating_point_arithmetic.rs:24:13
| |
LL | let _ = (1.0 + x * 2.0).ln(); LL | let _ = (1.0 + x * 2.0).ln();
| ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x * 2.0).ln_1p()` | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x * 2.0).ln_1p()`
error: ln(1 + x) can be computed more accurately error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:28:13 --> $DIR/floating_point_arithmetic.rs:25:13
| |
LL | let _ = (1.0 + x.powi(2)).ln(); LL | let _ = (1.0 + x.powi(2)).ln();
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(2).ln_1p()` | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(2).ln_1p()`
error: ln(1 + x) can be computed more accurately error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:29:13 --> $DIR/floating_point_arithmetic.rs:26:13
| |
LL | let _ = (1.0 + x.powi(2) * 2.0).ln(); LL | let _ = (1.0 + x.powi(2) * 2.0).ln();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x.powi(2) * 2.0).ln_1p()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x.powi(2) * 2.0).ln_1p()`
error: ln(1 + x) can be computed more accurately error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:30:13 --> $DIR/floating_point_arithmetic.rs:27:13
| |
LL | let _ = (1.0 + (std::f32::consts::E - 1.0)).ln(); LL | let _ = (1.0 + (std::f32::consts::E - 1.0)).ln();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `((std::f32::consts::E - 1.0)).ln_1p()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `((std::f32::consts::E - 1.0)).ln_1p()`
error: ln(1 + x) can be computed more accurately error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:37:13 --> $DIR/floating_point_arithmetic.rs:34:13
| |
LL | let _ = (1.0 + x).ln(); LL | let _ = (1.0 + x).ln();
| ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()`
error: ln(1 + x) can be computed more accurately error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:38:13 --> $DIR/floating_point_arithmetic.rs:35:13
| |
LL | let _ = (1.0 + x * 2.0).ln(); LL | let _ = (1.0 + x * 2.0).ln();
| ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x * 2.0).ln_1p()` | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x * 2.0).ln_1p()`
error: ln(1 + x) can be computed more accurately error: ln(1 + x) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:39:13 --> $DIR/floating_point_arithmetic.rs:36:13
| |
LL | let _ = (1.0 + x.powi(2)).ln(); LL | let _ = (1.0 + x.powi(2)).ln();
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(2).ln_1p()` | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(2).ln_1p()`
error: exponent for bases 2 and e can be computed more efficiently error: exponent for bases 2 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:48:13 --> $DIR/floating_point_arithmetic.rs:45:13
| |
LL | let _ = 2f32.powf(x); LL | let _ = 2f32.powf(x);
| ^^^^^^^^^^^^ help: consider using: `x.exp2()` | ^^^^^^^^^^^^ help: consider using: `x.exp2()`
|
= note: `-D clippy::slow-floating-point-computation` implied by `-D warnings`
error: exponent for bases 2 and e can be computed more efficiently error: exponent for bases 2 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:49:13 --> $DIR/floating_point_arithmetic.rs:46:13
| |
LL | let _ = std::f32::consts::E.powf(x); LL | let _ = std::f32::consts::E.powf(x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.exp()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.exp()`
error: square-root of a number can be computer more efficiently error: square-root of a number can be computed more efficiently and accurately
--> $DIR/floating_point_arithmetic.rs:50:13 --> $DIR/floating_point_arithmetic.rs:47:13
| |
LL | let _ = x.powf(1.0 / 2.0); LL | let _ = x.powf(1.0 / 2.0);
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.sqrt()` | ^^^^^^^^^^^^^^^^^ help: consider using: `x.sqrt()`
error: cube-root of a number can be computer more efficiently error: cube-root of a number can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:51:13 --> $DIR/floating_point_arithmetic.rs:48:13
| |
LL | let _ = x.powf(1.0 / 3.0); LL | let _ = x.powf(1.0 / 3.0);
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()` | ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()`
error: exponent for bases 2 and e can be computed more efficiently error: exponent for bases 2 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:54:13 --> $DIR/floating_point_arithmetic.rs:51:13
| |
LL | let _ = 2f64.powf(x); LL | let _ = 2f64.powf(x);
| ^^^^^^^^^^^^ help: consider using: `x.exp2()` | ^^^^^^^^^^^^ help: consider using: `x.exp2()`
error: exponent for bases 2 and e can be computed more efficiently error: exponent for bases 2 and e can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:55:13 --> $DIR/floating_point_arithmetic.rs:52:13
| |
LL | let _ = std::f64::consts::E.powf(x); LL | let _ = std::f64::consts::E.powf(x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.exp()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.exp()`
error: square-root of a number can be computer more efficiently error: square-root of a number can be computed more efficiently and accurately
--> $DIR/floating_point_arithmetic.rs:56:13 --> $DIR/floating_point_arithmetic.rs:53:13
| |
LL | let _ = x.powf(1.0 / 2.0); LL | let _ = x.powf(1.0 / 2.0);
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.sqrt()` | ^^^^^^^^^^^^^^^^^ help: consider using: `x.sqrt()`
error: cube-root of a number can be computer more efficiently error: cube-root of a number can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:57:13 --> $DIR/floating_point_arithmetic.rs:54:13
| |
LL | let _ = x.powf(1.0 / 3.0); LL | let _ = x.powf(1.0 / 3.0);
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()` | ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()`
error: (e.pow(x) - 1) can be computed more accurately error: (e.pow(x) - 1) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:62:13 --> $DIR/floating_point_arithmetic.rs:59:13
| |
LL | let _ = x.exp() - 1.0; LL | let _ = x.exp() - 1.0;
| ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()`
error: (e.pow(x) - 1) can be computed more accurately error: (e.pow(x) - 1) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:63:13 --> $DIR/floating_point_arithmetic.rs:60:13
| |
LL | let _ = x.exp() - 1.0 + 2.0; LL | let _ = x.exp() - 1.0 + 2.0;
| ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()`
error: (e.pow(x) - 1) can be computed more accurately error: (e.pow(x) - 1) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:69:13 --> $DIR/floating_point_arithmetic.rs:66:13
| |
LL | let _ = x.exp() - 1.0; LL | let _ = x.exp() - 1.0;
| ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()`
error: (e.pow(x) - 1) can be computed more accurately error: (e.pow(x) - 1) can be computed more accurately
--> $DIR/floating_point_arithmetic.rs:70:13 --> $DIR/floating_point_arithmetic.rs:67:13
| |
LL | let _ = x.exp() - 1.0 + 2.0; LL | let _ = x.exp() - 1.0 + 2.0;
| ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()`