2022-11-25 03:11:47 -06:00
|
|
|
// run-rustfix
|
|
|
|
|
2022-02-17 14:28:07 -06:00
|
|
|
struct Foo {
|
|
|
|
bar: Bar,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Bar {
|
|
|
|
qux: i32,
|
|
|
|
}
|
|
|
|
|
2022-03-23 21:47:45 -05:00
|
|
|
pub fn post_regular() {
|
2022-03-23 19:26:59 -05:00
|
|
|
let mut i = 0;
|
|
|
|
i++; //~ ERROR Rust has no postfix increment operator
|
|
|
|
println!("{}", i);
|
|
|
|
}
|
|
|
|
|
2022-03-23 21:47:45 -05:00
|
|
|
pub fn post_while() {
|
2022-03-23 19:26:59 -05:00
|
|
|
let mut i = 0;
|
|
|
|
while i++ < 5 {
|
|
|
|
//~^ ERROR Rust has no postfix increment operator
|
|
|
|
println!("{}", i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 21:47:45 -05:00
|
|
|
pub fn post_regular_tmp() {
|
2022-03-23 19:26:59 -05:00
|
|
|
let mut tmp = 0;
|
|
|
|
tmp++; //~ ERROR Rust has no postfix increment operator
|
|
|
|
println!("{}", tmp);
|
|
|
|
}
|
|
|
|
|
2022-03-23 21:47:45 -05:00
|
|
|
pub fn post_while_tmp() {
|
2022-03-23 19:26:59 -05:00
|
|
|
let mut tmp = 0;
|
|
|
|
while tmp++ < 5 {
|
|
|
|
//~^ ERROR Rust has no postfix increment operator
|
|
|
|
println!("{}", tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 21:47:45 -05:00
|
|
|
pub fn post_field() {
|
2022-11-25 03:11:47 -06:00
|
|
|
let mut foo = Foo { bar: Bar { qux: 0 } };
|
2022-02-17 14:28:07 -06:00
|
|
|
foo.bar.qux++;
|
|
|
|
//~^ ERROR Rust has no postfix increment operator
|
|
|
|
println!("{}", foo.bar.qux);
|
|
|
|
}
|
|
|
|
|
2022-03-23 21:47:45 -05:00
|
|
|
pub fn post_field_tmp() {
|
2022-02-17 16:58:46 -06:00
|
|
|
struct S {
|
|
|
|
tmp: i32
|
|
|
|
}
|
2022-11-25 03:11:47 -06:00
|
|
|
let mut s = S { tmp: 0 };
|
2022-02-17 16:58:46 -06:00
|
|
|
s.tmp++;
|
|
|
|
//~^ ERROR Rust has no postfix increment operator
|
|
|
|
println!("{}", s.tmp);
|
|
|
|
}
|
|
|
|
|
2022-03-23 21:47:45 -05:00
|
|
|
pub fn pre_field() {
|
2022-11-25 03:11:47 -06:00
|
|
|
let mut foo = Foo { bar: Bar { qux: 0 } };
|
2022-02-17 14:28:07 -06:00
|
|
|
++foo.bar.qux;
|
|
|
|
//~^ ERROR Rust has no prefix increment operator
|
|
|
|
println!("{}", foo.bar.qux);
|
|
|
|
}
|
|
|
|
|
2022-03-23 19:26:59 -05:00
|
|
|
fn main() {}
|