1 // does not test any rustfixable lints
3 #![warn(clippy::float_cmp_const)]
4 #![allow(clippy::float_cmp)]
5 #![allow(unused, clippy::no_effect, clippy::unnecessary_operation)]
10 fn eq_one(x: f32) -> bool {
11 if x.is_nan() { false } else { x == ONE } // no error, inside "eq" fn
27 // no errors, lower than or greater than comparisons
33 // no errors, zero and infinity values
37 ONE == f32::NEG_INFINITY;
39 // no errors, but will warn clippy::float_cmp if '#![allow(float_cmp)]' above is removed
46 const ZERO_ARRAY: [f32; 3] = [0.0, 0.0, 0.0];
47 const ZERO_INF_ARRAY: [f32; 3] = [0.0, f32::INFINITY, f32::NEG_INFINITY];
48 const NON_ZERO_ARRAY: [f32; 3] = [0.0, 0.1, 0.2];
49 const NON_ZERO_ARRAY2: [f32; 3] = [0.2, 0.1, 0.0];
51 // no errors, zero and infinity values
52 NON_ZERO_ARRAY[0] == NON_ZERO_ARRAY2[1]; // lhs is 0.0
53 ZERO_ARRAY == NON_ZERO_ARRAY; // lhs is all zeros
54 ZERO_INF_ARRAY == NON_ZERO_ARRAY; // lhs is all zeros or infinities
57 NON_ZERO_ARRAY == NON_ZERO_ARRAY2;