Skip to content

integer_arithmetic rule is too simplistic and is triggered even when arithmetic operations are applied to constants/literals that cannot cause overflow or panic #6209

Closed
@mimoo

Description

@mimoo

Hello, the following code triggers the integer-arithmetic rule:

warning: integer arithmetic detected
  --> client/json-rpc/src/blocking/client.rs:89:44
   |
89 |                 if expiration_time_secs <= state.timestamp_usecs / 1_000_000 {
   |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: requested on the command line with `-W clippy::integer-arithmetic`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#integer_arithmetic

I'm not sure how useful it is, as there is no danger here IIUC. The only edge-case is division by 0 right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.good first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions