Skip to content

manual_is_multiple_of suggests change that could alter behaviour #15335

@ojeda

Description

@ojeda

Description

a % b == 0 is not equivalent to a.is_multiple_of(b): b == 0 panics in the former, while it may return false or true in the latter.

However, the Clippy lint manual_is_multiple_of does not mention this potential change in behavior -- the user may or may not want the non-panicking behavior.

Therefore, should manual_is_multiple_of mention that the replacement may change behavior in b == 0 cases?

Example: https://godbolt.org/z/4883fo71s

(This is very similar to #14333 about manual_div_ceil, but for manual_is_multiple_of.)

Version

rustc 1.88.0 (6b00bc388 2025-06-23)

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-documentationArea: Adding or improving documentationC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions