]> git.lizzy.rs Git - rust.git/blob - tests/ui/modulo_arithmetic_float.rs
Fix type checks for `manual_str_repeat`
[rust.git] / tests / ui / modulo_arithmetic_float.rs
1 #![warn(clippy::modulo_arithmetic)]
2 #![allow(
3     unused,
4     clippy::shadow_reuse,
5     clippy::shadow_unrelated,
6     clippy::no_effect,
7     clippy::unnecessary_operation,
8     clippy::modulo_one
9 )]
10
11 fn main() {
12     // Lint when both sides are const and of the opposite sign
13     -1.6 % 2.1;
14     1.6 % -2.1;
15     (1.1 - 2.3) % (1.1 + 2.3);
16     (1.1 + 2.3) % (1.1 - 2.3);
17
18     // Lint on floating point numbers
19     let a_f32: f32 = -1.6;
20     let mut b_f32: f32 = 2.1;
21     a_f32 % b_f32;
22     b_f32 % a_f32;
23     b_f32 %= a_f32;
24
25     let a_f64: f64 = -1.6;
26     let mut b_f64: f64 = 2.1;
27     a_f64 % b_f64;
28     b_f64 % a_f64;
29     b_f64 %= a_f64;
30
31     // No lint when both sides are const and of the same sign
32     1.6 % 2.1;
33     -1.6 % -2.1;
34     (1.1 + 2.3) % (-1.1 + 2.3);
35     (-1.1 - 2.3) % (1.1 - 2.3);
36 }