]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/assign_ops.rs
Fix deploy.sh III
[rust.git] / tests / compile-fail / assign_ops.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3
4 #[deny(assign_ops)]
5 #[allow(unused_assignments)]
6 fn main() {
7     let mut i = 1i32;
8     i += 2; //~ ERROR assign operation detected
9     //~^ HELP replace it with
10     //~| SUGGESTION i = i + 2
11     i += 2 + 17; //~ ERROR assign operation detected
12     //~^ HELP replace it with
13     //~| SUGGESTION i = i + 2 + 17
14     i -= 6; //~ ERROR assign operation detected
15     //~^ HELP replace it with
16     //~| SUGGESTION i = i - 6
17     i -= 2 - 1;
18     //~^ ERROR assign operation detected
19     //~| HELP replace it with
20     //~| SUGGESTION i = i - (2 - 1)
21     i *= 5; //~ ERROR assign operation detected
22     //~^ HELP replace it with
23     //~| SUGGESTION i = i * 5
24     i *= 1+5; //~ ERROR assign operation detected
25     //~^ HELP replace it with
26     //~| SUGGESTION i = i * (1+5)
27     i /= 32; //~ ERROR assign operation detected
28     //~^ HELP replace it with
29     //~| SUGGESTION i = i / 32
30     i /= 32 | 5; //~ ERROR assign operation detected
31     //~^ HELP replace it with
32     //~| SUGGESTION i = i / (32 | 5)
33     i /= 32 / 5; //~ ERROR assign operation detected
34     //~^ HELP replace it with
35     //~| SUGGESTION i = i / (32 / 5)
36     i %= 42; //~ ERROR assign operation detected
37     //~^ HELP replace it with
38     //~| SUGGESTION i = i % 42
39     i >>= i; //~ ERROR assign operation detected
40     //~^ HELP replace it with
41     //~| SUGGESTION i = i >> i
42     i <<= 9 + 6 - 7; //~ ERROR assign operation detected
43     //~^ HELP replace it with
44     //~| SUGGESTION i = i << (9 + 6 - 7)
45     i += 1 << 5;
46     //~^ ERROR assign operation detected
47     //~| HELP replace it with
48     //~| SUGGESTION i = i + (1 << 5)
49 }
50
51 #[allow(dead_code, unused_assignments)]
52 #[deny(assign_op_pattern)]
53 fn bla() {
54     let mut a = 5;
55     a = a + 1; //~ ERROR manual implementation of an assign operation
56     //~^ HELP replace it with
57     //~| SUGGESTION a += 1
58     a = 1 + a; //~ ERROR manual implementation of an assign operation
59     //~^ HELP replace it with
60     //~| SUGGESTION a += 1
61     a = a - 1; //~ ERROR manual implementation of an assign operation
62     //~^ HELP replace it with
63     //~| SUGGESTION a -= 1
64     a = a * 99; //~ ERROR manual implementation of an assign operation
65     //~^ HELP replace it with
66     //~| SUGGESTION a *= 99
67     a = 42 * a; //~ ERROR manual implementation of an assign operation
68     //~^ HELP replace it with
69     //~| SUGGESTION a *= 42
70     a = a / 2; //~ ERROR manual implementation of an assign operation
71     //~^ HELP replace it with
72     //~| SUGGESTION a /= 2
73     a = a % 5; //~ ERROR manual implementation of an assign operation
74     //~^ HELP replace it with
75     //~| SUGGESTION a %= 5
76     a = a & 1; //~ ERROR manual implementation of an assign operation
77     //~^ HELP replace it with
78     //~| SUGGESTION a &= 1
79     a = 1 - a;
80     a = 5 / a;
81     a = 42 % a;
82     a = 6 << a;
83     let mut s = String::new();
84     s = s + "bla";
85 }