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