Skip to content

Disallow bitwise negation inside boolean context #46

Open
@ppershing

Description

@ppershing

Lint explanation

Bitwise negation might lead to hard-to-spot errors in case it is confused with a boolean negation.

Example code

let seq_id: u32;
if !seq_id > last_seq_id {/* deal with non-monotonic ids */}

Note that the code above is wrong and the intended code is

let seq_id: u32;
if !(seq_id > last_seq_id) {/* deal with non-monotonic ids */}

Notes

While this lint is very specific to if scenario above, we would be happy with a simple "no bitwise negation" lint as our codebase does not contain much of bit-twiddling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-user-storyArea: A user story or a related issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions