]> git.lizzy.rs Git - rust.git/blob - tests/ui/parser/increment-autofix-2.fixed
Merge commit '598f0909568a51de8a2d1148f55a644fd8dffad0' into sync_cg_clif-2023-01-24
[rust.git] / tests / ui / parser / increment-autofix-2.fixed
1 // run-rustfix
2
3 struct Foo {
4     bar: Bar,
5 }
6
7 struct Bar {
8     qux: i32,
9 }
10
11 pub fn post_regular() {
12     let mut i = 0;
13     i += 1; //~ ERROR Rust has no postfix increment operator
14     println!("{}", i);
15 }
16
17 pub fn post_while() {
18     let mut i = 0;
19     while { let tmp = i; i += 1; tmp } < 5 {
20         //~^ ERROR Rust has no postfix increment operator
21         println!("{}", i);
22     }
23 }
24
25 pub fn post_regular_tmp() {
26     let mut tmp = 0;
27     tmp += 1; //~ ERROR Rust has no postfix increment operator
28     println!("{}", tmp);
29 }
30
31 pub fn post_while_tmp() {
32     let mut tmp = 0;
33     while { let tmp_ = tmp; tmp += 1; tmp_ } < 5 {
34         //~^ ERROR Rust has no postfix increment operator
35         println!("{}", tmp);
36     }
37 }
38
39 pub fn post_field() {
40     let mut foo = Foo { bar: Bar { qux: 0 } };
41     foo.bar.qux += 1;
42     //~^ ERROR Rust has no postfix increment operator
43     println!("{}", foo.bar.qux);
44 }
45
46 pub fn post_field_tmp() {
47     struct S {
48         tmp: i32
49     }
50     let mut s = S { tmp: 0 };
51     s.tmp += 1;
52     //~^ ERROR Rust has no postfix increment operator
53     println!("{}", s.tmp);
54 }
55
56 pub fn pre_field() {
57     let mut foo = Foo { bar: Bar { qux: 0 } };
58     foo.bar.qux += 1;
59     //~^ ERROR Rust has no prefix increment operator
60     println!("{}", foo.bar.qux);
61 }
62
63 fn main() {}