]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/excessive_precision.fixed
Auto merge of #74777 - ssomers:btree_cleanup_7, r=Mark-Simulacrum
[rust.git] / src / tools / clippy / tests / ui / excessive_precision.fixed
1 // run-rustfix
2 #![warn(clippy::excessive_precision)]
3 #![allow(dead_code, unused_variables, clippy::print_literal)]
4
5 fn main() {
6     // Consts
7     const GOOD32: f32 = 0.123_456;
8     const GOOD32_SM: f32 = 0.000_000_000_1;
9     const GOOD32_DOT: f32 = 10_000_000_000.0;
10     const GOOD32_EDGE: f32 = 1.000_000_8;
11     const GOOD64: f64 = 0.123_456_789_012;
12     const GOOD64_SM: f32 = 0.000_000_000_000_000_1;
13     const GOOD64_DOT: f32 = 10_000_000_000_000_000.0;
14
15     const BAD32_1: f32 = 0.123_456_79_f32;
16     const BAD32_2: f32 = 0.123_456_79;
17     const BAD32_3: f32 = 0.1;
18     const BAD32_EDGE: f32 = 1.000_001;
19
20     const BAD64_1: f64 = 0.123_456_789_012_345_66_f64;
21     const BAD64_2: f64 = 0.123_456_789_012_345_66;
22     const BAD64_3: f64 = 0.1;
23
24     // Literal as param
25     println!("{:?}", 8.888_888_888_888_89);
26
27     // // TODO add inferred type tests for f32
28     // Locals
29     let good32: f32 = 0.123_456_f32;
30     let good32_2: f32 = 0.123_456;
31
32     let good64: f64 = 0.123_456_789_012;
33     let good64_suf: f64 = 0.123_456_789_012f64;
34     let good64_inf = 0.123_456_789_012;
35
36     let bad32: f32 = 1.123_456_8;
37     let bad32_suf: f32 = 1.123_456_8_f32;
38     let bad32_inf = 1.123_456_8_f32;
39
40     let bad64: f64 = 0.123_456_789_012_345_66;
41     let bad64_suf: f64 = 0.123_456_789_012_345_66_f64;
42     let bad64_inf = 0.123_456_789_012_345_66;
43
44     // Vectors
45     let good_vec32: Vec<f32> = vec![0.123_456];
46     let good_vec64: Vec<f64> = vec![0.123_456_789];
47
48     let bad_vec32: Vec<f32> = vec![0.123_456_79];
49     let bad_vec64: Vec<f64> = vec![0.123_456_789_123_456_78];
50
51     // Exponential float notation
52     let good_e32: f32 = 1e-10;
53     let bad_e32: f32 = 1.123_456_8e-10;
54
55     let good_bige32: f32 = 1E-10;
56     let bad_bige32: f32 = 1.123_456_8E-10;
57
58     // Inferred type
59     let good_inferred: f32 = 1f32 * 1_000_000_000.;
60
61     // issue #2840
62     let num = 0.000_000_000_01e-10f64;
63 }