Skip to content

manual_is_multiple_of triggers on arbitrary types implementing Rem and outputing an integer #15204

Closed
@samueltardieu

Description

@samueltardieu

Summary

Happy trigger

Lint Name

manual_is_multiple_of

Reproducer

I tried this code:

fn any_rem<T: std::ops::Rem<Output = u32>>(a: T, b: T) {
    // An arbitrary `Rem` implementation should not lint
    let _ = a % b == 0;
}

I saw this happen:

5 |     let _ = a % b == 0;
  |             ^^^^^^^^^^ help: replace with: `a.is_multiple_of(b)`

This should not trigger as .is_multiple_of() is only implemented on unsigned integer types by default.

Version

rustc 1.90.0-nightly (667787527 2025-07-02)
binary: rustc
commit-hash: 6677875279b560442a07a08d5119b4cd6b3c5593
commit-date: 2025-07-02
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7

Additional Labels

@rustbot label +I-suggestion-causes-error
@rustbot claim

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions