rust-lang / rust-lang/rust-clippy
Applying manual_clamp lint results in slower code
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Description
The manual_clamp lint nags me to replace .max(0).min(255) with .clamp(0,255) in image-webp crate, but doing that results in significantly slower code.
You can find the full details and the assembly comparison in the issue I opened on the rustc repo: https://github.com/rust-lang/rust/issues/141915
The root cause of the slowdown is still being investigated.
We've put an #[allow] on the affected piece of code in image-web, but it would be nice to disable this lint by default so it wouldn't cause any further performance regressions across the ecosystem.
Version
I've reproduced the regression on rustc 1.75, 1.82 and 1.87
Additional Labels
No response
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 reading the linked rustc issue and locating the manual_clamp lint in rust-clippy. Confirm how its default level is configured and identify the relevant lint tests before changing the default; done means the lint no longer causes this reported performance regression by default.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100