Skip to content

integer_division_remainder_used not triggered by inherent division methods #17603

Description

@tarcieri

Summary

This is a followup to #16490 which expanded this lint.

There are a number of inherent methods on integers that perform division which this lint should also catch. This is not an exhaustive list, but here are some that would be nice to catch:

  • checked_div
  • checked_div_euclid
  • checked_div_exact
  • checked_rem
  • checked_rem_euclid
  • div_ceil
  • div_euclid
  • div_exact
  • overflowing_div
  • overflowing_div_euclid
  • overflowing_rem
  • overflowing_rem_euclid
  • rem_euclid
  • strict_div
  • strict_div_euclid
  • saturating_div
  • strict_rem
  • strict_rem_euclid
  • wrapping_div
  • wrapping_div_euclid
  • wrapping_rem
  • wrapping_rem_euclid

Lint Name

integer_division_remainder_used

Reproducer

This is an example for div_ceil, but the problem persists for all of the above inherent methods:

#![warn(clippy::integer_division_remainder_used)]

pub fn div_ceil_by_three(x: u16) -> u16 {
    x.div_ceil(3)
}

Version

rustc 1.98.0 (88d9e12ae 2026-08-18)
binary: rustc
commit-hash: 88d9e12ae178fab0fb5cc050a94da85685d449ea
commit-date: 2026-08-18
host: aarch64-apple-darwin
release: 1.98.0
LLVM version: 22.1.8

Metadata

Metadata

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

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions