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