Summary
The lint triggers for expressions of the form (a + b - 1) / b but not of the form (a - 1) / b + 1. For unsigned integers, these are equivalent ignoring overflow/underflow.
Lint Name
manual_div_ceil
Reproducer
I tried this code (playground):
fn div_ceil(a: u32, b: u32) -> u32 {
(a - 1) / b + 1
}
I expected to see this happen:
The manual_div_ceil lint should trigger, suggesting a.div_ceil(b).
Instead, this happened:
Nothing.
Summary
The lint triggers for expressions of the form
(a + b - 1) / bbut not of the form(a - 1) / b + 1. For unsigned integers, these are equivalent ignoring overflow/underflow.Lint Name
manual_div_ceil
Reproducer
I tried this code (playground):
I expected to see this happen:
The
manual_div_ceillint should trigger, suggestinga.div_ceil(b).Instead, this happened:
Nothing.