rust-clippy/clippy_tests/examples/assign_ops.rs

42 lines
653 B
Rust
Raw Normal View History

2016-05-11 13:32:20 +00:00
#![feature(plugin)]
#![plugin(clippy)]
#[warn(assign_ops)]
2016-05-11 13:32:20 +00:00
#[allow(unused_assignments)]
fn main() {
let mut i = 1i32;
2017-02-08 13:58:07 +00:00
i += 2;
i += 2 + 17;
i -= 6;
2016-06-29 19:24:20 +00:00
i -= 2 - 1;
2017-02-08 13:58:07 +00:00
i *= 5;
i *= 1+5;
i /= 32;
i /= 32 | 5;
i /= 32 / 5;
i %= 42;
i >>= i;
i <<= 9 + 6 - 7;
2016-06-29 19:24:20 +00:00
i += 1 << 5;
2016-05-11 13:32:20 +00:00
}
#[allow(dead_code, unused_assignments)]
#[warn(assign_op_pattern)]
2016-05-11 13:32:20 +00:00
fn bla() {
let mut a = 5;
2017-02-08 13:58:07 +00:00
a = a + 1;
a = 1 + a;
a = a - 1;
a = a * 99;
a = 42 * a;
a = a / 2;
a = a % 5;
a = a & 1;
2016-05-11 13:32:20 +00:00
a = 1 - a;
a = 5 / a;
a = 42 % a;
a = 6 << a;
let mut s = String::new();
s = s + "bla";
}