rust-lang / rust-lang/rust-clippy
`arithmetic_side_effects` should trigger on `pow()`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
The .pow() method on integers is implicit about what happens on overflow and has each of the checked, overflowing, saturating, strict and wrapping variants, just like the other arithmetic operations. So it should be treated the same way in this lint.
Lint Name
arithmetic_side_effects
Reproducer
I tried this code:
#![deny(clippy::arithmetic_side_effects)]
fn foo(n: u32) -> u32 {
n.pow(20)
}
I expected to see this happen: The lint should trigger, just like it does for n + 1.
Instead, this happened: Nothing.
Version
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the arithmetic_side_effects lint implementation and its tests, then compare how pow() is handled with the existing n + 1 case. The work is done when the reproducer triggers the lint and a regression test covers the expected diagnostic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100