Description
Code
fn main(){
let mut i=10;
while i !=0{
i--;
}
}
Current output
error: expected expression, found `;`
--> teste.rs:4:12
|
4 | i--;
| ^ expected expression
error: aborting due to previous error
Desired output
error: Rust has no postfix decrement operator
--> ./testt.rs:4:10
|
4 | i--;
| ^^ not a valid postfix operator
|
help: use `-= 1` instead
|
4 | i -= 1;
| ~~~~
error: aborting due to previous error
Rationale and extra context
rust compiler throws error when postfix increment of prefix increment is used, but when decrement is it does not show where the problem is
for example this just compiles with no warning
fn main(){
let i=10;
let c=--i +1;
println!("{c}");
}
the output will be 11 which is not as expected
edit
--i is double negation is rust which I didn't know
but i-- give wrong error
Other cases
No response
Anything else?
No response