Skip to content

wrong clippy suggestion for div_ceil in macro definition #14665

Closed
@glorv

Description

@glorv

The source code is here https://github.com/tikv/tikv/blob/7467871cb55b4fe29cee23fa85f0e7fb89768d2b/components/file_system/src/rate_limiter.rs#L266
When I update rust-toolchain from nightly-2023-12-28 to nightly-2025-04-03 and run cargo clippy, it returns

I expected to see this happen: explanation

warning: manually reimplementing `div_ceil`
   --> components/file_system/src/rate_limiter.rs:266:23
    |
266 |                       * ((locked.pending_bytes[priority_idx] + cached_b...
    |  _______________________^
267 | |                         / cached_bytes_per_epoch) as u32
    | |_________________________________________________^ help: consider using `.div_ceil()`: `locked.pending_bytes[priority_idx].div_ceil(cached_bytes_per_epoch)`

Instead, this happened: explanation

warning: manually reimplementing `div_ceil`
   --> components/file_system/src/rate_limiter.rs:266:23
    |
266 |                       * ((locked.pending_bytes[priority_idx] + cached_b...
    |  _______________________^
267 | |                         / cached_bytes_per_epoch) as u32
    | |_________________________________________________^ help: consider using `.div_ceil()`: `locked.pending_bytes[priority_idx].div_ceil(request_imp!(self, priority, amount, sync))`

Meta

rustc --version --verbose:
The tool chain is nightly-2025-04-03

$ cargo --version
cargo 1.88.0-nightly (a6c604d1b 2025-03-26)
Backtrace

<backtrace>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions