fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
1.5 KiB58 linesraw
1#![allow(dead_code, clippy::double_parens, clippy::unnecessary_cast)]
2#![warn(clippy::suboptimal_flops, clippy::imprecise_flops)]
3
4const TWO: f32 = 2.0;
5const E: f32 = std::f32::consts::E;
6
7fn check_log_base() {
8    let x = 1f32;
9    let _ = x.log2();
10    let _ = x.log10();
11    let _ = x.ln();
12    let _ = x.log2();
13    let _ = x.ln();
14    let _ = (x as f32).log2();
15
16    let x = 1f64;
17    let _ = x.log2();
18    let _ = x.log10();
19    let _ = x.ln();
20}
21
22fn check_ln1p() {
23    let x = 1f32;
24    let _ = 2.0f32.ln_1p();
25    let _ = 2.0f32.ln_1p();
26    let _ = x.ln_1p();
27    let _ = (x / 2.0).ln_1p();
28    let _ = x.powi(3).ln_1p();
29    let _ = (x.powi(3) / 2.0).ln_1p();
30    let _ = (std::f32::consts::E - 1.0).ln_1p();
31    let _ = x.ln_1p();
32    let _ = x.powi(3).ln_1p();
33    let _ = (x + 2.0).ln_1p();
34    let _ = (x / 2.0).ln_1p();
35    // Cases where the lint shouldn't be applied
36    let _ = (1.0 + x + 2.0).ln();
37    let _ = (x + 1.0 + 2.0).ln();
38    let _ = (x + 1.0 / 2.0).ln();
39    let _ = (1.0 + x - 2.0).ln();
40
41    let x = 1f64;
42    let _ = 2.0f64.ln_1p();
43    let _ = 2.0f64.ln_1p();
44    let _ = x.ln_1p();
45    let _ = (x / 2.0).ln_1p();
46    let _ = x.powi(3).ln_1p();
47    let _ = x.ln_1p();
48    let _ = x.powi(3).ln_1p();
49    let _ = (x + 2.0).ln_1p();
50    let _ = (x / 2.0).ln_1p();
51    // Cases where the lint shouldn't be applied
52    let _ = (1.0 + x + 2.0).ln();
53    let _ = (x + 1.0 + 2.0).ln();
54    let _ = (x + 1.0 / 2.0).ln();
55    let _ = (1.0 + x - 2.0).ln();
56}
57
58fn main() {}