-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggest !
for bitwise negation when encountering a ~
#41679
Comments
And no, I'm not concerned about potential confusion with the ancient owned pointer syntax. :P |
If anyone wants to tackle this, you'll need to modify |
I would like to have a try. It seems that I need to emit a |
@F001 Worth asking on #rust-internals on irc.mozilla.org, or internals.rust-lang.org if you'd prefer something other than IRC. |
Suggest `!` for bitwise negation when encountering a `~` Fix rust-lang#41679 Here is a program ```rust fn main() { let x = ~1; } ``` It's output: ``` error: `~` can not be used as an unary operator --> /home/fcc/temp/test.rs:4:13 | 4 | let x = ~1; | ^^ | = help: use `!` instead of `~` if you meant to bitwise negation ``` cc @bstrie
Here's a program:
Its output:
Given that this is our only deviation from C-style bitwise operator syntax, it would be nice to have a note of some kind to suggest
!
here.Ideally the note would only appear when the
~
looks like it's being applied as a unary operator on a numeric type, but if that would require too much machinery then something simpler will suffice.The text was updated successfully, but these errors were encountered: