]> git.lizzy.rs Git - rust.git/blob - tests/ui/zero_div_zero.rs
rustup and compile-fail -> ui test move
[rust.git] / tests / ui / zero_div_zero.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3
4 #[allow(unused_variables)]
5 #[deny(zero_divided_by_zero)]
6 fn main() {
7     let nan = 0.0 / 0.0; //~ERROR constant division of 0.0 with 0.0 will always result in NaN
8                          //~^ equal expressions as operands to `/`
9     let f64_nan = 0.0 / 0.0f64; //~ERROR constant division of 0.0 with 0.0 will always result in NaN
10                          //~^ equal expressions as operands to `/`
11     let other_f64_nan = 0.0f64 / 0.0; //~ERROR constant division of 0.0 with 0.0 will always result in NaN
12                          //~^ equal expressions as operands to `/`
13     let one_more_f64_nan = 0.0f64/0.0f64; //~ERROR constant division of 0.0 with 0.0 will always result in NaN
14                          //~^ equal expressions as operands to `/`
15     let zero = 0.0;
16     let other_zero = 0.0;
17     let other_nan = zero / other_zero; // fine - this lint doesn't propegate constants.
18     let not_nan = 2.0/0.0; // not an error: 2/0 = inf
19     let also_not_nan = 0.0/2.0; // not an error: 0/2 = 0
20 }