1 #![warn(clippy::integer_arithmetic, clippy::float_arithmetic)]
2 #![allow(
3     unused,
4     clippy::shadow_reuse,
5     clippy::shadow_unrelated,
6     clippy::no_effect,
7     clippy::unnecessary_operation,
8     clippy::op_ref
9 )]
10 
11 #[rustfmt::skip]
main()12 fn main() {
13     let mut f = 1.0f32;
14 
15     f * 2.0;
16 
17     1.0 + f;
18     f * 2.0;
19     f / 2.0;
20     f - 2.0 * 4.2;
21     -f;
22 
23     f += 1.0;
24     f -= 1.0;
25     f *= 2.0;
26     f /= 2.0;
27 }
28 
29 // also warn about floating point arith with references involved
30 
float_arith_ref()31 pub fn float_arith_ref() {
32     3.1_f32 + &1.2_f32;
33     &3.4_f32 + 1.5_f32;
34     &3.5_f32 + &1.3_f32;
35 }
36 
float_foo(f: &f32) -> f3237 pub fn float_foo(f: &f32) -> f32 {
38     let a = 5.1;
39     a + f
40 }
41 
float_bar(f1: &f32, f2: &f32) -> f3242 pub fn float_bar(f1: &f32, f2: &f32) -> f32 {
43     f1 + f2
44 }
45 
float_baz(f1: f32, f2: &f32) -> f3246 pub fn float_baz(f1: f32, f2: &f32) -> f32 {
47     f1 + f2
48 }
49 
float_qux(f1: f32, f2: f32) -> f3250 pub fn float_qux(f1: f32, f2: f32) -> f32 {
51     (&f1 + &f2)
52 }
53