rust-lang / rust-lang/rust-clippy

Applying manual_clamp lint results in slower code

Open
#14,959 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

S-blocked
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.