rust-lang / rust-lang/rust-clippy

Split `suboptimal_flops` into smaller lints

Open
#6,867 17 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint S-needs-discussion
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

suboptimal_flops is very useful. Most of its suggestions are wins both for readability and performance, however some significantly reduce readability in my opinion.

E.g.

a * 2.0 + 3.0

is a lot more readable than

a.mul_add(2.0, 3.0)

in particular for new developers that may not be familiar with mul_add.

We'd love to enable suboptimal_flops for our code-base, but there is definitely some friction where it makes suggestions that just makes the code less readable in code that doesn't need the absolute maximum performance.

I propose splitting suboptimal_flops into two smaller lint groups such that one group contains all lints that improve performance and readability, and the other contains those that improve performance, but may impact readability negatively.

Drawbacks

More lint types

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 existing suboptimal_flops lint and its documented suggestions. Review the issue discussion to determine which suggestions belong in each new lint group, then verify that the groups can be configured independently and that the lint documentation and tests reflect the split.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.