]> git.lizzy.rs Git - rust.git/blob - tests/ui/arithmetic.rs
rustup and compile-fail -> ui test move
[rust.git] / tests / ui / arithmetic.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3
4 #![deny(integer_arithmetic, float_arithmetic)]
5 #![allow(unused, shadow_reuse, shadow_unrelated, no_effect, unnecessary_operation)]
6 fn main() {
7     let i = 1i32;
8     1 + i; //~ERROR integer arithmetic detected
9     i * 2; //~ERROR integer arithmetic detected
10     1 % //~ERROR integer arithmetic detected
11     i / 2; // no error, this is part of the expression in the preceding line
12     i - 2 + 2 - i; //~ERROR integer arithmetic detected
13     -i; //~ERROR integer arithmetic detected
14
15     i & 1; // no wrapping
16     i | 1;
17     i ^ 1;
18     i >> 1;
19     i << 1;
20
21     let f = 1.0f32;
22
23     f * 2.0; //~ERROR floating-point arithmetic detected
24
25     1.0 + f; //~ERROR floating-point arithmetic detected
26     f * 2.0; //~ERROR floating-point arithmetic detected
27     f / 2.0; //~ERROR floating-point arithmetic detected
28     f - 2.0 * 4.2; //~ERROR floating-point arithmetic detected
29     -f; //~ERROR floating-point arithmetic detected
30 }