Closed
Description
I find the error message confusing and possibly incorrect when attempting to use ~
as a unary operator:
In current Rust stable and nightly, I get:
error: `~` cannot be used as a unary operator
--> src/main.rs:5:11
|
5 | num = ~num + 1;
| ^ help: use `!` to perform bitwise negation
The "help" is misleading because it is suggesting using !
to "perform bitwise negation." But this is not really what ~ performs. NEG and NOT are two separate instructions which perform different things. I think this message would be best changed to "perform bitwise NOT" or "perform bitwise one's complement"