]> git.lizzy.rs Git - rust.git/blob - tests/ui/arithmetic.rs
Merge pull request #3285 from devonhollowood/pedantic-dogfood-items-after-statements
[rust.git] / tests / ui / arithmetic.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10
11 #![feature(tool_lints)]
12
13
14 #![warn(clippy::integer_arithmetic, clippy::float_arithmetic)]
15 #![allow(unused, clippy::shadow_reuse, clippy::shadow_unrelated, clippy::no_effect, clippy::unnecessary_operation)]
16 fn main() {
17     let i = 1i32;
18     1 + i;
19     i * 2;
20     1 %
21     i / 2; // no error, this is part of the expression in the preceding line
22     i - 2 + 2 - i;
23     -i;
24
25     i & 1; // no wrapping
26     i | 1;
27     i ^ 1;
28     i >> 1;
29     i << 1;
30
31     let f = 1.0f32;
32
33     f * 2.0;
34
35     1.0 + f;
36     f * 2.0;
37     f / 2.0;
38     f - 2.0 * 4.2;
39     -f;
40 }