Bit mask makes the expression a constant

ID

rust.correctness.bad_bit_mask

Severity

low

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Suspicious Construct

Language

Rust

Description

This bit mask makes the result independent of the operand: the expression always yields the same value, so the flag it is supposed to test is never really examined. Check the mask constant and the value compared against it.

Rationale

This bit mask makes the result independent of the operand: the expression always yields the same value, so the flag it is supposed to test is never really examined. Check the mask constant and the value compared against it.

The following code illustrates the pattern detected by this rule:

pub fn always_zero(flags: u32) -> u32 {
    // FLAGGED: Bit mask makes the expression a constant
    flags & 0
}

Remediation

Follow secure coding practices and review the references below for detailed remediation guidance.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved