Skip to content

integer_division_remainder_used not triggered by DivAssign/RemAssign #16490

@tarcieri

Description

@tarcieri

Summary

We had a line that looked like:

r1.0 /= TwoGamma2::U32;

For some reason that didn't trigger the lint. Seems it's a general problem with DivAssign/RemAssign

Full context: https://github.com/RustCrypto/signatures/pull/1144/files#diff-9d6b7776479a0f5978554cc71e1bba410f373fa4fc5fd1df3462e8a71e5f40deL67

(note: this was a potential security vulnerability it would've been nice to have caught)

Lint Name

integer_division_remainder_used

Reproducer

#![warn(clippy::integer_division_remainder_used)]

pub fn div_by_three(mut x: u16) -> u16 {
    x /= 3;
    x
}

pub fn rem_by_three(mut x: u16) -> u16 {
    x %= 3;
    x
}

Version

clippy 0.1.93 (254b59607d 2026-01-19)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions