2023-04-20 14:37:15 +00:00
|
|
|
//@run-rustfix
|
2022-10-02 09:53:58 +00:00
|
|
|
#![allow(dead_code, clippy::double_parens, clippy::unnecessary_cast)]
|
2020-02-24 05:06:55 +00:00
|
|
|
#![warn(clippy::suboptimal_flops, clippy::imprecise_flops)]
|
2020-02-23 04:32:13 +00:00
|
|
|
|
|
|
|
const TWO: f32 = 2.0;
|
|
|
|
const E: f32 = std::f32::consts::E;
|
|
|
|
|
|
|
|
fn check_log_base() {
|
|
|
|
let x = 1f32;
|
|
|
|
let _ = x.log2();
|
|
|
|
let _ = x.log10();
|
|
|
|
let _ = x.ln();
|
|
|
|
let _ = x.log2();
|
|
|
|
let _ = x.ln();
|
2022-08-29 20:36:11 +00:00
|
|
|
let _ = (x as f32).log2();
|
2020-02-23 04:32:13 +00:00
|
|
|
|
|
|
|
let x = 1f64;
|
|
|
|
let _ = x.log2();
|
|
|
|
let _ = x.log10();
|
|
|
|
let _ = x.ln();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn check_ln1p() {
|
|
|
|
let x = 1f32;
|
|
|
|
let _ = 2.0f32.ln_1p();
|
|
|
|
let _ = 2.0f32.ln_1p();
|
|
|
|
let _ = x.ln_1p();
|
2020-02-23 08:04:11 +00:00
|
|
|
let _ = (x / 2.0).ln_1p();
|
2020-04-03 16:58:52 +00:00
|
|
|
let _ = x.powi(3).ln_1p();
|
|
|
|
let _ = (x.powi(3) / 2.0).ln_1p();
|
2021-04-01 01:39:44 +00:00
|
|
|
let _ = (std::f32::consts::E - 1.0).ln_1p();
|
2020-02-23 04:32:13 +00:00
|
|
|
let _ = x.ln_1p();
|
2020-04-03 16:58:52 +00:00
|
|
|
let _ = x.powi(3).ln_1p();
|
2020-02-23 04:32:13 +00:00
|
|
|
let _ = (x + 2.0).ln_1p();
|
2020-02-23 08:04:11 +00:00
|
|
|
let _ = (x / 2.0).ln_1p();
|
2020-02-23 04:32:13 +00:00
|
|
|
// Cases where the lint shouldn't be applied
|
|
|
|
let _ = (1.0 + x + 2.0).ln();
|
|
|
|
let _ = (x + 1.0 + 2.0).ln();
|
2020-02-23 08:04:11 +00:00
|
|
|
let _ = (x + 1.0 / 2.0).ln();
|
2020-02-23 04:32:13 +00:00
|
|
|
let _ = (1.0 + x - 2.0).ln();
|
|
|
|
|
|
|
|
let x = 1f64;
|
|
|
|
let _ = 2.0f64.ln_1p();
|
|
|
|
let _ = 2.0f64.ln_1p();
|
|
|
|
let _ = x.ln_1p();
|
2020-02-23 08:04:11 +00:00
|
|
|
let _ = (x / 2.0).ln_1p();
|
2020-04-03 16:58:52 +00:00
|
|
|
let _ = x.powi(3).ln_1p();
|
2020-02-23 04:32:13 +00:00
|
|
|
let _ = x.ln_1p();
|
2020-04-03 16:58:52 +00:00
|
|
|
let _ = x.powi(3).ln_1p();
|
2020-02-23 04:32:13 +00:00
|
|
|
let _ = (x + 2.0).ln_1p();
|
2020-02-23 08:04:11 +00:00
|
|
|
let _ = (x / 2.0).ln_1p();
|
2020-02-23 04:32:13 +00:00
|
|
|
// Cases where the lint shouldn't be applied
|
|
|
|
let _ = (1.0 + x + 2.0).ln();
|
|
|
|
let _ = (x + 1.0 + 2.0).ln();
|
2020-02-23 08:04:11 +00:00
|
|
|
let _ = (x + 1.0 / 2.0).ln();
|
2020-02-23 04:32:13 +00:00
|
|
|
let _ = (1.0 + x - 2.0).ln();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|