Skip to content

Catch xor vs power confusion #4205

@kornelski

Description

@kornelski

2x is often written in ASCII as 2^x, but in Rust this happens to xor the value instead of raising it to the power.

let bad  = 2^31;
let good = 1<<31;

Apparently, people make that mistake, and so far it goes undetected:

https://twitter.com/johnregehr/status/1139302389612077056

Metadata

Metadata

Assignees

Labels

A-lintArea: New lintsL-suggestionLint: Improving, adding or fixing lint suggestionsgood first issueThese issues are a good way to get started with Clippy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions