]> git.lizzy.rs Git - rust.git/blob - src/test/ui/parser/increment-autofix-2.rs
Auto merge of #103600 - compiler-errors:early-binder-nits, r=spastorino
[rust.git] / src / test / ui / parser / increment-autofix-2.rs
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++; //~ ERROR Rust has no postfix increment operator
14     println!("{}", i);
15 }
16
17 pub fn post_while() {
18     let mut i = 0;
19     while i++ < 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++; //~ 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 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++;
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++;
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;
59     //~^ ERROR Rust has no prefix increment operator
60     println!("{}", foo.bar.qux);
61 }
62
63 fn main() {}