Skip to content

Consider deprecating integer_arithmetic in favor of arithmetic_side_effects #10200

Closed
@c410-f3r

Description

@c410-f3r

Even though both lints can live separated, perhaps it might be worth considering deprecating integer_arithmetic in favor of arithmetic_side_effects.

  1. arithmetic_side_effects can detect arithmetic operations of any type, not only integers, which prevents more runtime overflows or panics.
  2. integer_arithmetic fires on trivial operations that in fact shouldn't be linted. On the other hand, arithmetic_side_effects is smarter.
    2.1. Adding or Subtracting 0¹: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=8c37520d26e4e59a85b419efc32c02c8
    2.2. Multiplying 1 or 0¹: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=5e95f95870e7cb6d6c3df178b98c2bd2
    2.3. CTFE: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=5144fb63c938b3796e65f91007eae9b0
    2.4. References: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=46c03f3b0851c376113f8ea161e92d08
    2.5. You can take a look at other spotted cases in https://github.com/rust-lang/rust-clippy/pulls?q=is%3Apr+author%3Ac410-f3r+is%3Aclosed.
¹: Used to reinforce the arguments. It its known that no_effect and similar exist.

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