Skip to content
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

Lint on uses of XOR as if it were POW: 2 ^ 32 #61934

Closed
estebank opened this issue Jun 18, 2019 · 3 comments
Closed

Lint on uses of XOR as if it were POW: 2 ^ 32 #61934

estebank opened this issue Jun 18, 2019 · 3 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@estebank
Copy link
Contributor

Given 2^32 is a common enough mistake to make, to the point that GCC is adding a lint for it, we probably should lint 2 ^ 8, 2 ^ 16, 2 ^ 32 and 2 ^ 64 as well and suggest 2u64.pow(x) or even better std::u64::MAX.

@estebank estebank added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label Jun 18, 2019
@jonas-schievink
Copy link
Contributor

rust-lang/rust-clippy#4213 implements this in clippy

@nagisa
Copy link
Member

nagisa commented Jun 18, 2019

This does not really pass the bar for no-false-positive-lints-in-rustc and is also RFC material.

@estebank
Copy link
Contributor Author

Closing in lieu of the clippy lint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

3 participants